$this->AddOutput("<p><b>Email: " . $this->Value('email') . "</b></p>"); $this->AddOutput("<p><b>Phone: " . $this->Value('phone') . "</b></p>"); return true; } } */ // ----------------------------------------------------------------------- // // Use the form and check it status. // session_name('cform_example'); session_start(); $form = new \Mos\HTMLForm\CForm(array(), array('name' => array('type' => 'text', 'label' => 'Name of contact person:', 'required' => true, 'validation' => array('not_empty')), 'email' => array('type' => 'text', 'required' => true, 'validation' => array('not_empty', 'email_adress')), 'phone' => array('type' => 'text', 'required' => true, 'validation' => array('not_empty', 'numeric')), 'submit' => array('type' => 'submit', 'callback' => function ($form) { $form->AddOutput("<p><i>DoSubmit(): Form was submitted. Do stuff (save to database) and return true (success) or false (failed processing form)</i></p>"); $form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>"); $form->AddOutput("<p><b>Email: " . $form->Value('email') . "</b></p>"); $form->AddOutput("<p><b>Phone: " . $form->Value('phone') . "</b></p>"); $form->saveInSession = true; return true; }), 'submit-fail' => array('type' => 'submit', 'callback' => function ($form) { $form->AddOutput("<p><i>DoSubmitFail(): Form was submitted but I failed to process/save/validate it</i></p>"); return false; }))); // Check the status of the form $status = $form->Check(); // What to do if the form was submitted? if ($status === true) { $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>"); header("Location: " . $_SERVER['PHP_SELF']); } else {