Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
There is a need to pass values from the parent form to the child form using relationship behavior in the Backend of an application. In the parent controller, the `relationExtendManageWidget()` function is overridden, and the model used in the widget of the child form is accessed using `$widget->config->model`. Then, a dynamic property is added to the model using the `addDynamicProperty()` function, so that this property is not saved to the database, as it is only used for filtering logic. ``` public function relationExtendManageWidget($widget, $field, $model) { if($field == 'actresses' && property_exists($widget->config, 'context') ) { $widget->config->model->addDynamicProperty('_active_continent_id', $model->continent_id); } } ``` To use it, for example, there is a dropdown in the child form to display a list of countries in the selected continent previously selected in the parent form, then we simply do: ``` country: label: 'Country' nameFrom: name span: full type: relation scope: '\Foo\Bar\Actress::getFilteredCountryBasedOnContinent' ``` Then, the function is filled in as follows: ``` static public function getFilteredCountryBasedOnContinent($query, $model) { $query ->where('continent_id', $model->_active_continent_id); } ```
References
Add additional online resources to your trick
×
Name
URL
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline