Kontrollkästchen (mehrere) Formularfeldtyp
From Joomla! Documentation
Der checkboxes Formularfeldtyp bietet ein Satz an Kontrollkästchen.
Hinweis: Im Gegensatz zu den meisten Standardformularfeldtypen, wie textfield oder checkbox, ist dieses Feld keine "out of the box" Lösung. Es wird mehrere Kontrollkästchen für dich erstellen und sendet die Werte in Form eines Arrays, welche jedoch nicht in der Datenbank gespeichert werden.
Beispiel:
<field name="toppings" type="checkboxes">
<option value="anch">Anchovies</option>
<option value="chor">Chorizo</option>
<option value="on">Onions</option>
<option value="mush">Mushrooms</option>
</field>
Dieser Satz von Kontrollkästchen kann in Form einer Angabe wie folgender erzeugt werden:
<?php echo $this->form->getInput('toppings'); ?>
Dabei wird folgendes HTML erzeugt, welches durch CSS gestaltet werden kann.
<fieldset id="jform_toppings" class="checkboxes">
<ul>
<li><input type="checkbox" id="jform_toppings0"
name="jform[toppings][]" value="anch" /><label for="jform_toppings0">Anchovies</label></li>
<li><input type="checkbox" id="jform_toppings1"
name="jform[toppings][]" value="chor" /><label for="jform_toppings1">Chorizo</label></li>
<li><input type="checkbox" id="jform_toppings2"
name="jform[toppings][]" value="on" /><label for="jform_toppings2">Onions</label></li>
<li><input type="checkbox" id="jform_toppings3"
name="jform[toppings][]" value="mush" /><label for="jform_toppings3">Mushrooms</label></li>
</ul>
</fieldset>
Wenn nun ein Benutzer das zweite und vierte Element wählt und das Formular versendet, so wird der Joomla-Server folgendes Ergebnis zur Verfügung stellen:
print_r(JRequest::getVar('jform')['toppings']) =>
Array
(
[0] => chor
[1] => mush
)