Example #1
0
 public function __construct(Form $form, $name, $type = self::TEXT, $label = null, $labelPosition = self::LABEL_BEFORE)
 {
     $name = Strings::stringToUnderScore($name);
     $this->_name = $name;
     $this->_id = $form->getId() . '-' . Strings::urlize($name);
     $this->setOption('name', $name);
     $this->setOption('id', $this->_id);
     $this->_type = $type;
     $this->_label = $label === null ? Strings::humanize($name) : $label;
     $this->_labelPosition = $labelPosition;
     $this->_form = $form;
 }
Example #2
0
 public function renderElements(Form $form)
 {
     $return = '';
     if ($this->_elementGroupType !== null) {
         $return = '<' . $this->_elementGroupType . '>';
     }
     foreach ($form->getElements() as $element) {
         $return .= $element->render();
     }
     if ($this->_elementGroupType !== null) {
         $return .= '</' . $this->_elementGroupType . '>';
     }
     return $return;
 }
Example #3
0
 public function testFromClass()
 {
     $user = new User();
     $form = Form::fromClass($user);
     $form->hydrate(['username' => 'myuser', 'password' => 'test', 'null_value' => '', 'emptyValue' => '']);
     $this->assertEquals('myuser', $form->getValue('username'));
     $this->assertSame(null, $form->getValue('nullValue'));
     $this->assertSame('', $form->getValue('emptyValue'));
 }