Skip to content

Instantly share code, notes, and snippets.

@estefanionsantos
Last active September 8, 2021 12:08
Show Gist options
  • Save estefanionsantos/a1515d2fb99db5ff87daab937e18493c to your computer and use it in GitHub Desktop.
Save estefanionsantos/a1515d2fb99db5ff87daab937e18493c to your computer and use it in GitHub Desktop.
fieldset form rubricate
<?php
use Rubricate\Form\FieldsetForm;
use Rubricate\Form\LabelForm;
use Rubricate\Form\CheckboxForm;
$elem = new FieldsetForm('Category:');
for ($i = 1; $i <= 3; $i++) {
$checkbox = new CheckboxForm('checkbox[]', $i);
$option = $checkbox->getElement() . ' Option ' . $i;
$label = new LabelForm($option);
$elem->addChild($label);
}
echo $elem->getElement();
/*
<fieldset>
<legend>Category:</legend>
<label>
<input type="checkbox" name="checkbox[]" value="1" /> Option 1
</label>
<label>
<input type="checkbox" name="checkbox[]" value="2" /> Option 2
</label>
<label>
<input type="checkbox" name="checkbox[]" value="3" /> Option 3
</label>
</fieldset>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment