Basic Example

Formagic code

// create a Formagic instance
$form = new Formagic();

// add a default text input to the form
        'label' => 'My first input'

// Formagic::addItem() also accepts pre-instantiated items
$textarea = $form->createItem('textarea', 'myTextarea');

$submitButton = new Formagic_Item_Submit(
    'mySubmit', array(
        'label' => 'Send'

// check if the form has be submitted
if ($form->isSubmitted()) {
    echo "submitted";

    // set form to readonly

// render the form and output the result
echo $form->render();



You might have noticed that the textarea item in the example does not have a label. Formagic will not add default labels if you choose to skip assigning one.

Leave a Reply

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