# Select

# Basic usage

Default Selected is Apple.

To build an array of options in PHP file, each array must have value and text, which represent the value of options and the displayed text, respectively.

Route::get('demo', function() {
    return view('demo-view', [
        'select1_option' => [
            [
                'value' => 11,
                'text' => 'Watermelon'
            ],
            [
                'value' => 22,
                'text'  => 'Apple'
            ],
            [
                'value' => 23,
                'text'  => 'Banana',
            ]
        ],
    ]);
});

In the demo-view view file, set $radio1_option is passed to the input-select component.

<x-input-select name="select1" :options="$select1_option" :value="22" ></x-input-select>
显示代码

# Option Group

Default selected is Apple.

To build an array of options in PHP file, each array must have value and text, which represent the value of options and the displayed text, respectively.

Route::get('demo', function() {
    return view('demo-view', [
        'select2_option' => [
            [
                'text' => '水果', // 组名字
                'children' => [
                    [
                        'value' => 11,
                        'text' => 'Watermelon' //option text
                    ],
                    [
                        'value' => 22,
                        'text'  => 'Apple',
                        'prop'  => 'disabled', // You can disable an option
                    ],
                    [
                        'value' => 23,
                        'text'  => 'Banana'
                    ]
                ]
            ],
            [
                'text' => 'Vegetables',
                'prop'  => 'disabled', // You also can disable an group
                'children' => [
                    [
                        'value' => 21,
                        'text' => 'Leek'
                    ],
                    [
                        'value' => 33,
                        'text'  => 'kidney bean'
                    ],
                    [
                        'value' => 44,
                        'text'  => 'Chinese cabbage'
                    ]
                ]
            ]
        ],
    ]);
});

In the demo-view view file, set $select2_option is passed to the input-select component.

<x-input-select-group name="select2" :options="$select2_option" :value="22" ></x-input-select-group>
显示代码

# Option Array Rule

We have agreed on the option data used in the radio. Each option needs to have the following fields.

  • Select Option:
Field Required Type Description
value Required int 或 string The value of the option, which is finally passed to the form
text Required string Option is used to display the page
prop No Required string It is used to control certain features of a single option, eg: disabled, see API docs look more.
  • Select Group Option:
Field Required Type Description
text Required string group name
children Required array The array of options of group, each option is a normal Select Option