/** * Add element to the form. * * @param string $name * @param \Rapid\Form\Element $element * * @return Form */ public function addElement($name, \Rapid\Form\Element $element) { $element->setAttribute('name', $this->elementName($name)); $element->setAttribute('id', $this->elementId($name)); if ($this->model && $this->model->property($name)) { $element->setValue($this->model->property($name)); } $this->elements[$name] = $element; return $this; }
public function testSetValue() { $this->assertNull($this->element->value()); $this->assertInstanceOf('Rapid\\Form\\Element', $this->element->setValue(1)); $this->assertEquals(1, $this->element->value()); }