PHP code example of creode / collapsible-radios

1. Go to this page and download the library: Download creode/collapsible-radios library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

creode / collapsible-radios example snippets


use Creode\CollapseRadios\Field\CollapsibleRadios;

CollapsibleRadios::make('Model', 'model_id')
    ->options([
        [
            'label' => 'Option 1',
            'value' => 1,
            'id' => 1,
            'parent_id' => null,
        ],
        [
            'label' => 'Option 2',
            'value' => 2,
            'id' => 2,
            'parent_id' => 1,
        ],
                [
            'label' => 'Option 3',
            'value' => 3,
            'id' => 3,
            'parent_id' => 2,
        ]
    ])
    ->nullable()
    ->rules('

use Creode\CollapseRadios\Field\CollapsibleRadios;

CollapsibleRadios::make('Model', 'model_id')
    ->options(
        Model::all()->map(
            function ($model) {
                return [
                    'label' => $model->name,
                    'value' => $model->id,
                    'id' => $model->id,
                    'parent_id' => $model->parent_id ?: null,
                ];
            }
        )
    )
    ->nullable()
    ->rules('