示例#1
0
 /**
  * Renders the whole form, wrapping a table in <form> tags.
  *
  * @param  Form $form
  *
  * @return string
  *
  * @since 2.0
  */
 public function renderForm(Form $form)
 {
     $content = '';
     foreach ($form as $element) {
         $content .= $this->render($element);
     }
     $form->setAttribute('role', 'form');
     return Html::tag('form', $form->getAttributes(), $content);
 }
 /**
  * Creates a new comment form
  *
  * @return Form
  */
 protected function createCommentForm()
 {
     $form = new Form();
     $form['comment'] = (new Input\Textarea('comment'))->setLabel(gettext('Comment'));
     $form['internal'] = (new Input\Checkbox('internal'))->setLabel(gettext('Is internal?'));
     $form->setAttribute('method', 'POST');
     $form['submit'] = (new Input\Button('submit'))->setAttribute('type', 'submit')->setContents(gettext('Add comment'));
     return $form;
 }