0

I am trying to implement a multi choice for a custom field.

Currently i use form factory with this for simple fields :

$fieldset->addField(
            'mail',
            'text',
            ['name' => 'mail', 'label' => __('Mail'), 'title' => __('Mail'), 'required' => true]
        );

Now i want checkbox or multiselect, i already see this :

$fieldset->addField(
            'test',
            'multiselect',
            [
                'name' => 'name',
                'label' => __('test'),
                'title' => __('test'),
                'required' => true,
                'values' => $optionLanguage,
                'disabled' => false
            ]
        );

But I don't know how to write my $optionLanguage array, I just want simple option (option 1: Fr, option 2: En).

Don't matter checkbox or multiselect, checkbox is better for me but if multiselect is easier i will go for it.

1

Found solution for multiselect :

'values' => array(
            '1'=> array( 'label' => 'Français', 'value' => 'fr'),
            '2'=> array( 'label' => 'English', 'value' => 'en'),
            '3'=> array( 'label' => 'Espanol', 'value' => 'es'),
            '4'=> array( 'label' => 'Italiano', 'value' => 'it'),
            '5'=> array( 'label' => 'Deutsch', 'value' => 'de'),
            '6'=> array( 'label' => 'Român', 'value' => 'ro'),
          ),
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.