示例#1
0
 /**
  * @return bool
  */
 public static function validateDate(IControl $control)
 {
     $year = $control->year;
     $month = $control->month;
     $day = $control->day;
     if (!$control->isRequired() && $year === $month && $month === $day && $day === '') {
         return TRUE;
     } elseif ($year > 0 && $month > 0 && $day > 0) {
         return checkdate($month, $day, $year);
     } else {
         return FALSE;
     }
 }
示例#2
0
 /**
  * Renders 'control' part of visual row of controls.
  * @return string
  */
 public function renderControl(Nette\Forms\IControl $control)
 {
     $body = $this->getWrapper('control container');
     if ($this->counter % 2) {
         $body->class($this->getValue('control .odd'), TRUE);
     }
     $description = $control->getOption('description');
     if ($description instanceof Html) {
         $description = ' ' . $control->getOption('description');
     } elseif (is_string($description)) {
         $description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
     } else {
         $description = '';
     }
     if ($control->isRequired()) {
         $description = $this->getValue('control requiredsuffix') . $description;
     }
     if ($this->getValue('control errors')) {
         $description .= $this->renderErrors($control);
     }
     if ($control instanceof Nette\Forms\Controls\Checkbox || $control instanceof Nette\Forms\Controls\Button) {
         return $body->setHtml((string) $control->getControl() . (string) $control->getLabel() . $description);
     } else {
         return $body->setHtml((string) $control->getControl() . $description);
     }
 }
 /**
  * Renders 'control' part of visual row of controls.
  * @return string
  */
 public function renderControl(Nette\Forms\IControl $control)
 {
     $body = $this->getWrapper('control container');
     if ($this->counter % 2) {
         $body->class($this->getValue('control .odd'), TRUE);
     }
     $description = $control->getOption('description');
     if ($description instanceof Html) {
         $description = ' ' . $description;
     } elseif (is_string($description)) {
         $description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
     } else {
         $description = '';
     }
     if ($control->isRequired()) {
         $description = $this->getValue('control requiredsuffix') . $description;
     }
     $control->setOption('rendered', TRUE);
     $el = $control->getControl();
     if ($el instanceof Html && $el->getName() === 'input') {
         $el->class($this->getValue("control .{$el->type}"), TRUE);
     }
     return $body->setHtml($el . $description . $this->renderErrors($control));
 }
 /**
  * Renders 'control' part of visual row of controls.
  * @return string
  */
 public function renderControl(Nette\Forms\IControl $control)
 {
     $body = $this->getWrapper('control container');
     if ($this->counter % 2) {
         $body->class($this->getValue('control .odd'), TRUE);
     }
     $description = $control->getOption('description');
     if ($description instanceof Html) {
         $description = ' ' . $description;
     } elseif (is_string($description)) {
         $description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
     } else {
         $description = '';
     }
     if ($control->isRequired()) {
         $description = $this->getValue('control requiredsuffix') . $description;
     }
     $el = $control->getControl();
     if ($control instanceof Nette\Forms\Controls\TextInput || $control instanceof Nette\Forms\Controls\TextArea || $control instanceof Nette\Forms\Controls\SelectBox || $control instanceof Nette\Forms\Controls\MultiSelectBox) {
         $el->class($this->getValue("control form-control"), TRUE);
     }
     if ($control instanceof Nette\Forms\Controls\Checkbox) {
         //$el = $control->getLabel()->insert(0, $el);//reapair in NF 2.1RC3
         $elTemp = $el;
         $el = Html::el('div', array("class" => $this->getValue("pair containerCheckbox")));
         $el->setHtml($elTemp);
     }
     if ($this->isFormHorizontal() && $control instanceof Nette\Forms\Controls\Checkbox) {
         $div = Html::el('div', array("class" => $this->getValue("control col-offset")));
     } else {
         if ($this->isFormHorizontal()) {
             $div = Html::el('div', array("class" => $this->getValue("control col")));
         } else {
             $div = Html::el();
         }
     }
     $div->setHtml($el . $description . $this->renderErrors($control));
     return $body->addHtml($div);
 }
 /**
  * Renders 'label' part of visual row of controls.
  * @param \Nette\Forms\IControl $control
  * @return string
  */
 public function renderLabel(\Nette\Forms\IControl $control)
 {
     if (!$control instanceof \Nette\Forms\Controls\Checkbox && !$control instanceof \Nette\Forms\Controls\Button) {
         if ($control->isRequired()) {
             $label = $control->getLabel();
             $caption = $label->getText();
             $required = \Nette\Utils\Html::el('small');
             $required->setText($this->requiredLabel);
             $label->setHtml($caption . " " . (string) $required);
             return $label;
         }
     }
     return parent::renderLabel($control);
 }