/** * Add an element to the tray * * @param Element $formElement Element to add * @param boolean $required true = entry required * * @return void */ public function addElement(Element $formElement, $required = false) { $this->elements[] = $formElement; if ($required) { $formElement->setRequired(); } }
/** * @covers Xoops\Form\Element::isRequired */ public function testIsRequired() { $value = $this->object->isRequired(); $this->assertFalse($value); $this->object->setRequired(); $value = $this->object->isRequired(); $this->assertTrue($value); }
/** * addElement - Add an element to the form * * @param Element $formElement Xoops\Form\Element to add * @param boolean $required true if this is a required element * * @return void */ public function addElement(Element $formElement, $required = false) { /* @var Element $formElement */ $this->elements[] = $formElement; if ($formElement instanceof ContainerInterface) { /* @var $formElement ContainerInterface */ $required_elements = $formElement->getRequired(); $count = count($required_elements); for ($i = 0; $i < $count; ++$i) { $this->required[] = $required_elements[$i]; } } else { if ($required && !$formElement instanceof Raw) { $formElement->setRequired(); $this->required[] = $formElement; } } }
/** * Adding new element * @param Element $element * @param bool $required * @param bool $pre_fill * @return Element * @throws FormException */ public function addElement($element, $required = false, $pre_fill = true) { if ($element instanceof Element) { $element->setRequired($required); $element->setPreFill($pre_fill); $this->elements[] = $element; if ($element instanceof InputFile) { $this->setEnctype('multipart/form-data'); } return $element; } else { throw new FormException('element is not instance of class Element!'); } }
/** * setRequired - mark an element as required entry * * @param Element $formElement Xoops\Form\Element to set as required entry * * @return void * * @deprecated set required attribute on element directly or when calling addElement */ public function setRequired(Element $formElement) { $formElement->setRequired(); }