Renderer Example

$form = new Formagic();

// switch to XHTML renderer - 
// referenced by name for this example

// load class and create item instance in one step
$subContainer = Formagic::createItem(
        'label' => 'Sub-Container'
    ->addItem('input', 'subInput', array(
        'label' => 'Input in subcontainer',
    ->addItem('checkbox', 'subCheckbox', array(
        'label' => 'Checkbox in subcontainer'

// assign filter to item
    ->addItem('input', 'myInput', array(
        'label' => 'Input outside of subcontainer',
    ->addItem('submit', 'mySubmit', array(
        'label' => 'Send'

// print form
if ($form->validate()) {
    echo '<p class="submitted">
        <strong>Form status:</strong><br />

echo $form->render();





You can either set a new renderer by providing it’s name (that it it’s class name without prefix). You may of course set a previously created renderer instance as well. For this example we switched from default HTML table renderer to XHTML fieldset renderer.

Leave a Reply

Your email address will not be published. Required fields are marked *