$validationErrors = new Interview\ErrorContainer(); // UI $nicknameUI = new Group((new HTML\Label('Your Name'))->addCssClass('col-sm-2'), (new Div((new HTML\Input('text'))->setAttribute('placeholder', 'Your username')))->addCssClass('col-sm-10')); $emailUI = new Group((new HTML\Label('Your Email'))->addCssClass('col-sm-2'), (new Div(new HTML\Input('email')))->addCssClass('col-sm-10')); $textUI = new Group((new HTML\Label('Your Text'))->addCssClass('col-sm-2'), (new Div(new HTML\Textarea()))->addCssClass('col-sm-10')); $formUI = (new HTML\Form('post'))->addCssClass('form-horizontal'); $errorDiv = new HTML\ErrorContainer(); $successDiv = (new Div())->addCssClass('has-success')->setContent('<p>Your blog entry was submitted!</p>'); $formUI->appendChildren($nicknameUI, $emailUI, $textUI); $formUI->appendChild((new HTML\Button('submit'))->setContent('Publish!')); // Putting data model and UI together $formForBlogPost->setDisplay($formUI); $formForBlogPost->setFieldDisplay('nickname', $nicknameUI); $formForBlogPost->setFieldDisplay('email', $emailUI); $formForBlogPost->setFieldDisplay('text', $textUI); $validationErrors->setDisplay($errorDiv); // The Interviewer "HTMLForm" is executed $htmlForm = new Interview\HTMLForm(0, $validationErrors, $formForBlogPost); $htmlForm->setSuccessDisplay($successDiv); $htmlForm->execute(); // Display error messages first, in case something goes wrong print $validationErrors; // Display success message on successful form submission print $successDiv; // Display form fields (if applicable) print $htmlForm->getCurrentCollection(); // Proof that it worked (not really necessary) if ($htmlForm->getStatus() === Interview\InterviewInterface::STATUS_AFTER_INTERVIEW) { $article = new HTML\Element('article'); $article->addCssClass('blog'); $article->appendChild((new HTML\Element('h2'))->setContent('Most recent blog post'));