This is the size field display.
I have the size field code like this:
CRUD::addField([ 'label' => 'Size', 'type' => 'checklist', 'name' => 'size', 'entity' => 'sizes', 'attribute' => 'name', 'model' => 'AppModelsSize', 'pivot' => false, ]);
How do I change it to store the size’s name?
Advertisement
Answer
I solved this by creating a pivot table between merch and sizes and then changing the type of the column size.
$this->crud->addColumns( [ [ 'label' => 'Sizes', 'type' => "select_multiple", 'entity' => 'sizes', // the method that defines the relationship in your Model 'name' => 'sizes', 'attribute' => "name", // foreign key attribute that is shown to user 'model' => "AppModelsSize", 'pivot' => true, ], ]);