Skip to content

Allow to initialize CascadeDropdown values#1659

Merged
mvorisek merged 7 commits intodevelopfrom
feature/cascade-dropdown-init-value
Oct 3, 2021
Merged

Allow to initialize CascadeDropdown values#1659
mvorisek merged 7 commits intodevelopfrom
feature/cascade-dropdown-init-value

Conversation

@ibelar
Copy link
Copy Markdown
Contributor

@ibelar ibelar commented Sep 14, 2021

Two values for proper initialization of the DropdownCascade is need: The actual value of the dropdown and the reference value for populating the dropdown items.

Usage:

$form = Form::addTo($app);

$form->addControl('cat', [Form\Control\Dropdown::class, 'model' => new Category($app->db)])->set(2);

$form->addControl('sub', [Form\Control\DropdownCascade::class, 'cascadeFrom' => 'cat', 'reference' => Category::hinting()->fieldName()->SubCategories])->set(9);

$form->addControl('prod', [Form\Control\DropdownCascade::class, 'cascadeFrom' => 'sub', 'reference' => SubCategory::hinting()->fieldName()->Products])->set(3)

Screen Shot 2021-09-14 at 3 10 11 PM

@mvorisek
Copy link
Copy Markdown
Member

mvorisek commented Sep 15, 2021

If the 'category_id' and 'sub_category_id' is from some demo/doc, replace it with SubCategory::hinting()->fieldName()->...

Also check the default values in Behat test.

@ibelar ibelar added the RTM label Sep 25, 2021
@mvorisek mvorisek merged commit 6282ae5 into develop Oct 3, 2021
@mvorisek mvorisek deleted the feature/cascade-dropdown-init-value branch October 3, 2021 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants