Exemplo n.º 1
0
 protected function _makeName($key, $controlName)
 {
     $groupName = $this->_group->getName();
     if ($groupName) {
         $name = sprintf('%s[%s][%s]', $groupName, $controlName, $key);
     } else {
         $name = sprintf('%s[%s]', $controlName, $key);
     }
     return $name;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider providerTestValidate
  * @param array $formData
  * @param bool $actual
  */
 public function testValidate($formData, $actual)
 {
     $attributes = array();
     $title = new Miao_Form_Control_Text('title', $attributes);
     $title->addValidator(new Miao_Form_Validate_Length(5));
     $url = new Miao_Form_Control_Text('url', $attributes);
     $url->setRequired();
     $group = new Miao_Form_Control_Group('group');
     $group->addControl($title);
     $group->addControl($url);
     $group->setValue($formData);
     $expected = $group->validate();
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 3
0
 /**
  * Create Group control, use it when you need multi block controls.
  *
  * @example
  * <code>
  * <input type="text" name="title[]" />
  * <input type="text" name="url[]" />
  * </code>
  *
  * @param string $name Group name, may be empty.
  * @param array $controls
  * @return \Miao_Form_Control_Group
  */
 public function addGroup($name, array $controls)
 {
     $obj = new Miao_Form_Control_Group($name);
     foreach ($controls as $control) {
         $obj->addControl($control);
     }
     $this->addControl($obj);
     return $obj;
 }