Cristopher Paiva
Cristopher Paiva

Reputation: 13

Tab Attribute Splits Forms into Tabs

I'm new to this laravel and backpack thing. Anyway, I have a form that I would like to divide into tabs. I have read the documentation, I found how to create the tabs but I do not know how to insert the forms in each tabs. Can anyone help me?

$this->crud->addField([
        'name'            => 'property_data',
        'label'           => "Select from array",
        'type'            => 'select_from_array',
        'options'         => ['one' => 'One', 'two' => 'Two', 'three' => 'Three'],
        'allows_null'     => false,
        'allows_multiple' => true,
        'tab'             =>  'Datos de la propiedad','Datos de la propiedad',
        ]);

Upvotes: 0

Views: 943

Answers (1)

john_ch
john_ch

Reputation: 111

In your Backpack CRUD controller within the setupCreateOperation() method, each addField() needs to have 1 value in the tab, so change yours to:

    $this->crud->addField([
    'name'            => 'property_data',
        'label'           => "Select from array",
        'type'            => 'select_from_array',
        'options'         => ['one' => 'One', 'two' => 'Two', 'three' => 'Three'],
        'allows_null'     => false,
        'allows_multiple' => true,
        'tab'             =>  'Tab 1',
        ]);

$this->crud->addField([
    'name'            => 'property_data_2',
        'label'           => "Select from array",
        'type'            => 'select_from_array',
        'options'         => ['one' => 'One', 'two' => 'Two', 'three' => 'Three'],
        'allows_null'     => false,
        'allows_multiple' => true,
        'tab'             =>  'Tab 2',
        ]);

The tab attribute should only have 1 value instead of the 2 separated by a comma. As you add more fields to your Backpack CRUD form, they will be pulled into the tab specified under 'tab' as long as you only keep one string as the value, ex: 'tab' => 'Tab 1', 'tab' => 'Tab 2', etc. You can reuse the strings for Tab multiple times, if you have 5 fields that you want in Tab 1, give each 'tab'=> 'Tab 1' and all 5 will show under this tab.

Upvotes: 1

Related Questions