Create a CheckBox

Hello,

I want to add a field with a checkbox to the record entry form.

I tried the plugin ElementTypes without success. I found this code but I don’t know where to integrate it :

$form->addElement(‘checkbox’, ‘access’, array(
‘label’ => __(‘Access’),
‘description’ => __(‘Acces’),
‘rows’ => 10
));


Thank you for your help!

Olivier

Rather than adding a checkbox, you could use the Simple Vocab plugin to apply a controlled vocabulary to your field. In the example below, I’ve added two choices – True and False – for the Dublin Core: Type element, resulting in a dropdown menu on the form.

Simple Vocab Settings

Choose the element and add one choice per line…

Item Form

Use the item form to choose from one of the two available choices…

This is effectively the same as a checkbox in that it is either true or false, on or off.

1 Like