Skip to content

Instantly share code, notes, and snippets.

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