Option list examples.
Option list examplesMultiple, single and text input elements have option lists. Here are some more detailed examples.
<?php
require_once '../../HtmlForm.php';
$form->addMultiple('multipleCheckbox', [
'required' => true,
'label' => 'Multiple-checkbox',
'list' => [
'option one' => 'label one',
'option two' => 'label two',
'option three' => 'label three',
],
]);
$form->addMultiple('multipleSelect', [
'label' => 'Multiple-select',
'skin' => 'select',
'list' => [
'label one',
'label two',
'label three',
],
]);
$form->addSingle('singleCheckbox', [
'required' => true,
'label' => 'Single-radiobutton',
'list' => [
'option one' => 'label one',
'option two' => 'label two',
'option three' => 'label three',
],
]);
$form->addSingle('singleSelect', [
'label' => 'Single-select',
'skin' => 'select',
'list' => [
'label one',
'label two',
'label three',
],
]);
$form->addSingle('optgroupSingle', [
'label' => 'Optgroup-single',
'skin' => 'select',
'list' => [
'group one' => [
'option one' => 'label one',
'option two' => 'label two',
'option three' => 'label three',
],
'group two' => [
'option four' => 'label four',
'option five' => 'label five',
],
],
]);
$form->addText('datalistText', [
'label' => 'Text with datalist',
'list' => [
'option one',
'option two',
'option three',
],
]);
$form->process();
if ($form->validate()) {
echo('<a href="">back</a>');
echo('<pre>');
var_dump($form->getValues());
echo('</pre>');
$form->clearSession();
} else {
?>
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="../../lib/css/depage-forms.css">
</head>
<body>
<?php echo($form); ?>
</body>
<?php
}