PHP code example of dft / silverstripe-frontend-multiselectfield

1. Go to this page and download the library: Download dft/silverstripe-frontend-multiselectfield 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/ */

    

dft / silverstripe-frontend-multiselectfield example snippets



$form = Form::create(
    FieldList::create(
        FrontendMultiSelectField::create(
            'Fruit',
            'Fruit',
            Fruit::get()
                ->map('ID', 'Title')
                ->toArray()
        )
    ),
    FieldList::create(
        FormAction::create(
            'doMyAction',
            'Submit Form'
        )
    )
);

FrontendMultiSelectField::create(
    'Fruit',
    'Fruit',
    Fruit::get()
        ->map('ID', 'Title')
        ->toArray()
)->setSearch(false);

FrontendMultiSelectField::create(
    'Fruit',
    'Fruit',
    Fruit::get()
        ->map('ID', 'Title')
        ->toArray()
)->setSelectAll(false);

FrontendMultiSelectField::create(
    'Fruit',
    'Fruit',
    Fruit::get()
        ->map('ID', 'Title')
        ->toArray()
)->limit(5); // Limits to a maximum of 5 items