/** * Render field label. * * Checks {@see FieldInterface::shouldRendererRenderLabel()} * before rendering. * * @param FieldInterface $field The field object to be rendered. * @return string The label, rendered in HTML, safe for output. * */ public function renderFieldLabel(FieldInterface $field) { if (!$field->shouldRendererRenderLabel()) { return; } $label = $field->getLabel(); $forAttribute = ''; $HTMLID = $field->getForAttributeInLabel(); if ($HTMLID != NULL) { $forAttribute = " for=\"{$HTMLID}\""; } return "<div class=\"fieldLabelContainer\">\n <label{$forAttribute}>{$label}</label>\n </div>"; }
/** * Add a field to this form. * * Add as many fields as you need: * * <code> * $form->addField($usernameField); * $form->addField($passwordField); * </code> * * @param Field $field Instance of FieldInterface. * */ public function addField(FieldInterface $field) { $id = $field->getID(); $label = $field->getLabel(); $this->labels[$id] = $label; $this->fields[$id] = $field; }