Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here

Complex Multi-Group Form

This project demonstrates how to organize form checkboxes into groups with restrictions to choose values only from one group.

17-complex-multi-group-form

Get the Source Code:

How it works

The main logic here lives between form() method on our Resource and the create and edit functions

  • Three different groups of checkboxes - Users, Groups, Positions
  • Each group has a set of checkboxes that can't be mixed. For example, if you selected Users, you can't select any other group
  • Each of the checkbox is reactive and generated real-time for the form.
  • There is a hydration logic for the checkboxes, so that when you edit the form, the checkboxes are pre-selected.
  • We will override the input format on both create and edit actions using CreateTask and EditTask files to fit our new format and save relationships manually

Here's how that looks in our form() method:

return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\DatePicker::make('due_date'),
// New section with checkboxes
Forms\Components\Section::make('Assignees')
->schema([
// We are creating a new fieldset for Users
Forms\Components\Fieldset::make('Users')
->extraAttributes(['class' => 'text-primary-600'])
// We are creating 1 column for the fieldset
->columns(1)
// We are setting the column span to 1
->columnSpan(1)
->schema(
// Here we dynamically generate checkboxes for each user by querying the database
 
// ...
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 64 Premium Examples for $99