Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement manage attaching and detaching nested relationships in OctoberCMS? #5796

Open
devmansurov opened this issue Apr 20, 2024 · 1 comment

Comments

@devmansurov
Copy link

I looked at an example here for creating data using nested relationships, but I didn’t understand how to manage the attachment and detachment of nested relationship data.

How to create and make partials correctly in this case?

OctoberCMS version: 2.x (not 3.x)

@mrmaarek
Copy link

First of all; I would recommend you to update to the newest version.

As shown in the information you should just provide a partial type-field for example:

models/customer/fields.yaml

orders:
  label: Orders
  type: partial
  path: field_orders

It wil reference to the controller directory; in this case: controllers/customers/_field_orders.htm

<?= $this->relationRender('orders') ?>

Because the controller has access to the relation functionality (see $implements)
it will look up for the relation yaml file in: controllers/customers/config_relation.yaml

which will render the relation based on the configuration:

orders:
    label: Order
    view:
        list: $/acme/formist/models/order/columns.yaml
        toolbarButtons: create|delete
    manage:
        form: $/acme/formist/models/order/fields.yaml
        list: $/acme/formist/models/order/columns.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants