Formagic code
// create a Formagic instance $form = new Formagic(); // add a default text input to the form $form->addItem( 'input', 'myInput', array( 'label' => 'My first input' ) ); // Formagic::addItem() also accepts pre-instantiated items $textarea = $form->createItem('textarea', 'myTextarea'); $form->addItem($textarea); $submitButton = new Formagic_Item_Submit( 'mySubmit', array( 'label' => 'Send' ) ); $form->addItem($submitButton); // check if the form has be submitted if ($form->isSubmitted()) { echo "submitted"; // set form to readonly $form->setReadonly(true); } // render the form and output the result echo $form->render();
Result
Description
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.