0
votes

enter image description here

Not inserted multi select value in database.

My fields.yaml Code is :

 related_recipe:
        label: 'Related Recipe'
        span: auto
        nameFrom: recipe_title
        descriptionFrom: description
        attributes: {multiple:'multiple'}
        type: relation

My model code is :

public $belongsTo = [

                    'related_recipe' => [
                         'Qdata\Taeq\Models\Recipe',
                      'conditions' => 'status = 1'
                      ],

                 ];

Currently only one selected value inserted in database.need add multiple value in database. Can any one have the solution of it ?

2
@VijayWilson i want to set the data using type = "relation" not partial.Ashish Detroja

2 Answers

0
votes

You should use a $belongsToMany relation in this case.

$belongsTo means your model is link with a single entity of your Recipe model.

0
votes

To do so with relation you need to go with "belongsToMany" relation. for example: In your Model 'related_recipes' => [ 'Qdata\Taeq\Models\Recipe', 'table' => 'pivot_table_name', 'key' => 'foreign_key_of_pivot_table', 'otherKey' => 'other_key', ], In related another Model 'makers' => [ 'Qdata\Taeq\Models\AnotherModel', 'table' => 'pivot_table_name', 'key' => 'foreign_key_of_pivot_table', 'otherKey' => 'other_key', ], this will save your multiselect dropdown data in the related pivot table in your database.