Topics

Radio usage example

Usage example

<?php
$form = new \Ip\Form();
// Add values and indexes
$values = array(
    array('1', 'First'),
    array('2', 'Second'),
    array('3', 'Third')
);
 
// Another way to add radio buttons
$values = array('First', 'Second', 'Third'); 
 
// Add a field
$form->addField(new \Ip\Form\Field\Radio(
    array(
        'name' => 'myRadio', // set HTML 'name' attribute
        'values' => $values,
        'value' => 2 // Check a second item
)));
echo $form->render();

Since ImpressPages 4.2.3 version $values can be passed as one level array 

$values = array('First', 'Second', 'Third');
comments powered by Disqus