Пример #1
0
 public static function _renderFieldset(HTML_QuickForm2_Renderer $renderer, HTML_QuickForm2_Container_Fieldset $fieldset)
 {
     $break = HTML_Common2::getOption('linebreak');
     $html[] = '<fieldset' . $fieldset->getAttributes(true) . '>';
     $label = $fieldset->getLabel();
     if (!empty($label)) {
         $html[] = sprintf('<legend id="%s-legend">%s</legend>', $fieldset->getId(), $label);
     }
     $elements = array_pop($renderer->html);
     $html[] = implode($break, $elements);
     $html[] = '</fieldset>';
     return implode($break, $html) . $break;
 }
Пример #2
0
 public function getLabel()
 {
     $label = (array) parent::getLabel();
     if (preg_match('/plus-minus/', $label[0])) {
         return $label;
     }
     if ($this->getAttribute('data-hidden')) {
         $sign = '+';
         $points = '&hellip;';
     } else {
         $sign = '&minus;';
         $points = '';
     }
     $label[0] = '[<span class="plus-minus"><b>' . $sign . '</b></span>]&nbsp;' . $label[0] . '<span class="dots">' . $points . '</span>';
     return $label;
 }
 public function testValidatorAlwaysPresentWhenClientRulesAdded()
 {
     $fieldset = new HTML_QuickForm2_Container_Fieldset();
     $repeat = new HTML_QuickForm2_Container_Repeat(null, null, array('prototype' => $fieldset));
     $fieldset->addText('foo')->addRule('required', 'Required!', null, HTML_QuickForm2_Rule::CLIENT_SERVER);
     $repeat->setIndexes(array());
     $renderer = HTML_QuickForm2_Renderer::factory('array');
     $renderer->getJavascriptBuilder()->setFormId('fake-repeat');
     $repeat->render($renderer);
     $this->assertContains('new qf.Validator', $renderer->getJavascriptBuilder()->getValidator());
 }
 public function testLegend()
 {
     $fs = new HTML_QuickForm2_Container_Fieldset(null, null, array('label' => 'legend'));
     $this->assertRegExp('!\\s*<fieldset[^>]+>\\s*<legend id="[^"]+-legend">legend</legend>\\s*</fieldset>\\s*!', $fs->__toString());
 }