示例#1
0
 public function testSetLabel()
 {
     $this->element->setLabel('My Label');
     $this->assertEquals('<label>My Label</label>', $this->element->label());
     $this->element->setAttribute('id', 'xxx');
     $this->assertEquals('<label for="xxx">My Label</label>', $this->element->label());
 }
示例#2
0
文件: Form.php 项目: creogen/rapidphp
 /**
  * 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;
 }