Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

How to use morphable multiple select that related together(like choose two category and then choose some sub category of them) In Subfields? #479

Closed rainbow1997 closed 1 year ago

rainbow1997 commented 1 year ago

Discussed in https://github.com/Laravel-Backpack/community-forum/discussions/478

Originally posted by **rainbow1997** May 4, 2023 I have a problem to use morphable related selects in subfields of laravel backpack. Actually, How can I use this code in backpack subfields? ```php CRUD::field('colorable') ->label(trans('translate.to')) ->addMorphOption('App\Models\PlexiColor', trans("translate.plexi_color"), [ 'type' => 'select2_from_ajax', 'attribute' => "name", 'entity' => 'colorable', 'model' => "App\Models\PlexiColor", 'data_source' => backpack_url('board-color-price/fetch/plexi-color'), 'minimum_input_length' => 0, 'method' => 'POST', 'include_all_form_fields' => true, ]) ->addMorphOption('App\Models\MultiStyleColor', trans("translate.multistyle_colors"), [ 'type' => 'select2_from_ajax', 'attribute' => "name", 'entity' => 'colorable', 'model' => "App\Models\MultiStyleColor", 'data_source' => backpack_url('board-color-price/fetch/multistyle-color'), 'minimum_input_length' => 0, 'method' => 'POST', 'include_all_form_fields' => true, ]) ->addMorphOption('App\Models\StealColor', trans("translate.steal_colors"), [ 'type' => 'select2_from_ajax', 'attribute' => "name", 'entity' => 'colorable', 'model' => "App\Models\StealColor", 'data_source' => backpack_url('board-color-price/fetch/steal-color'), 'minimum_input_length' => 0, 'method' => 'POST', 'include_all_form_fields' => true, ]) ->addMorphOption('App\Models\PleximirrorColor', trans("translate.Pleximirror_colors"), [ 'type' => 'select2_from_ajax', 'attribute' => "name", 'entity' => 'colorable', 'model' => "App\Models\PleximirrorColor", 'data_source' => backpack_url('board-color-price/fetch/pleximirror-colors'), 'minimum_input_length' => 0, 'method' => 'POST', 'include_all_form_fields' => true, ]) ->morphTypeField(['wrapper' => ['class' => 'form-group col-md-6']]) ->morphIdField(['wrapper' => ['class' => 'form-group col-md-6'], 'placeholder' => trans('translate.choose'),]); ``` I did many things but it doesn't work! for example: I use addMorphOption like array in subfield but it doesn't work.
rainbow1997 commented 1 year ago

@tabacitu please help me!

tabacitu commented 1 year ago

Sorry @rainbow1997 this doesn't seem like a bug to me, but a community question, so I'm going to close it.