novafieldcheckboxes
novafieldcheckboxes copied to clipboard
Allow displaying nested checkboxes
A method isChild() was added to src/SortableCheckboxes.php that checks whether the current checkbox is a child
Usage Exemple :
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
$checkBoxes = [];
$categories = Category::with('subCategories')->get();
foreach ($categories as $category) {
$checkBoxes [] = Checkboxes::make('', 'categories')
->options([$category->id => $category->name])
->withoutTypeCasting()->hideFromIndex();
foreach ($category->subCategories as $subCategory) {
$checkBoxes [] = Checkboxes::make('', 'sub_categories')
->options([$subCategory->id => $subCategory->name])
->isChild()
->withoutTypeCasting()->hideFromIndex();
}
}
return $checkBoxes;
}
Display result :

Please review this pull request
Apologies for the delay in responding to this and thanks for the PR @fouedmoussi .
Looks like a useful addition. My only issue with this is the replaced formPreview screenshot. If you could either put the original back in or include something that more closely matches the original, that would be great.
Thanks again.
Is it possible to merge this pull request?