public function testIdentity() { $element2 = unserialize(serialize($this->element)); $this->assertTrue($this->element->equals($element2)); $element3 = new Element(); $this->assertTrue($element2->getID() == $element3->getID() - 1); }
public function addElement(Element $element) { $element->setForm($this); //If the element doesn't have a specified id, a generic identifier is applied. $id = $element->getID(); if (empty($id)) { $element->setID($this->attributes['id'] . '-element-' . sizeof($this->elements)); } $this->elements[] = $element; /*For ease-of-use, the form tag's encytype attribute is automatically set if the File element class is added.*/ if ($element instanceof Element\File) { $this->attributes['enctype'] = 'multipart/form-data'; } }
protected function renderLabel(Element $element) { $label = $element->getLabel(); $id = $element->getID(); $description = $element->getDescription(); if (!empty($label) || !empty($description)) { echo '<div class="pfbc-label">'; if (!empty($label)) { echo '<label for="', $id, '">'; if ($element->isRequired()) { echo '<strong>*</strong> '; } echo $label, '</label>'; } if (!empty($description)) { echo '<em>', $description, '</em>'; } echo '</div>'; } }