amargoCactus
02/09/2022, 12:06 PM`Sebastlan
02/09/2022, 12:08 PMHarings Rob
02/09/2022, 12:09 PMifox
02/09/2022, 12:10 PMa17-fieldset component directly for now with :open="true/false"amargoCactus
02/09/2022, 12:11 PMprotected function formData($request)
{
$categories = ProductCategory::all()->map(function ($category) {
return ['label' => $category->name, 'value' => $category->id];
})->toArray();
return [
'categories' => $categories
];
}
form view:
@formField('select', [
'name' => 'category_id',
'label' => 'Category',
'placeholder' => 'Select a category',
'options' => $categories
])kalle
02/09/2022, 12:11 PM`Sebastlan
02/09/2022, 12:11 PMamargoCactus
02/09/2022, 12:12 PMHarings Rob
02/09/2022, 12:13 PMamargoCactus
02/09/2022, 12:13 PMamargoCactus
02/09/2022, 12:13 PMifox
02/09/2022, 12:14 PMcreate.blade.php file next to your form.blade.php filekalle
02/09/2022, 12:14 PMphp
/*
* Add anything you would like to have available in your module's form view
* For example, relationship lists for multiselect form fields
*/
protected function formData($request)
{
// Category here is assumed
return [
'categories' => app(CategoryRepository::class)->listAll(),
];
}amargoCactus
02/09/2022, 12:15 PMamargoCactus
02/09/2022, 12:15 PMifox
02/09/2022, 12:15 PMifox
02/09/2022, 12:16 PMlistAll? you're using the model directly in your current codeamargoCactus
02/09/2022, 12:17 PMamargoCactus
02/09/2022, 12:20 PMamargoCactus
02/09/2022, 12:21 PMlistAllifox
02/09/2022, 12:21 PMpublic function listAll($column = 'title', $orders = [], $exceptId = null)ifox
02/09/2022, 12:22 PMlistAll('name') in your caseamargoCactus
02/09/2022, 12:24 PMamargoCactus
02/09/2022, 12:35 PMamargoCactus
02/09/2022, 3:49 PMformData function doesnt work for create.blade.php ?pboivin
02/09/2022, 3:58 PMindexData() for the create modalamargoCactus
02/09/2022, 3:59 PMamargoCactus
02/09/2022, 3:59 PMpboivin
02/09/2022, 4:00 PMindex view.kalle
02/09/2022, 4:03 PMgetIndexData and append your custom key = > value so it will be available in the create form