Наследование: implements Nette\Forms\IFormRenderer, use trait Nette\SmartObject
Пример #1
0
 public function renderControl(Forms\IControl $control)
 {
     $result = parent::renderControl($control);
     if ($control instanceof Controls\TextBase && $control->getOption('help-bottom') !== NULL) {
         $result->add(Html::el('p class=help-block')->setText($control->getOption('help-bottom')));
     }
     return $result;
 }
Пример #2
0
 /**
  * @param \Nette\Forms\Form $form
  * @param string|null $mode
  * @return string
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->class[] = 'form-horizontal';
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->setAttribute('class', empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = true;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->setAttribute('class', 'form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->class($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
Пример #3
0
 /**
  * Initializes form.
  */
 protected function init()
 {
     parent::init();
     $label =& $this->wrappers['label'];
     $c =& $this->wrappers['control'];
     foreach ($this->form->getControls() as $name => $control) {
         if ($control instanceof \Nette\Forms\Controls\TextArea || $control instanceof \Nette\Forms\Controls\SelectBox) {
             $control->setAttribute('class', $c['.textarea-class'] . ' ' . $control->getControlPrototype()->class);
         } elseif ($control instanceof \Nette\Forms\Controls\SubmitButton) {
             if ($name === 'reset') {
                 $control->getControlPrototype()->class('btn btn-danger button red float-l');
             }
         }
         $control->getLabelPrototype()->class($label['.class'], TRUE);
     }
 }
 /**
  * Provides complete form rendering.
  * @param  Nette\Forms\Form
  * @param  string 'begin', 'errors', 'ownerrors', 'body', 'end' or empty to render all
  * @return string
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->addClass('form-inline');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             if (strpos($control->getControlPrototype()->getClass(), 'btn') === FALSE) {
                 $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
                 $usedPrimary = true;
             }
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
Пример #5
0
 /**
  * @param Form $form
  * @param string $mode
  * @return string
  */
 public function render(Form $form, $mode = NULL)
 {
     $this->form = $form;
     if ($mode !== NULL) {
         parent::render($form, $mode);
     }
     $template = $this->getTemplate();
     $template->form = $template->_form = $form;
     $template->renderer = $this;
     $template->view = $this->view;
     if (!$template->getFile()) {
         $template->setFile(__DIR__ . '/templates/form.latte');
     } else {
         $template->formTemplate = __DIR__ . '/templates/form.latte';
     }
     $this->beforeRender();
     $template->render();
 }
Пример #6
0
 public function render(\Nette\Forms\Form $form, $mode = null)
 {
     $this->wrappers['controls']['container'] = 'div class=col-sm-12';
     $this->wrappers['pair']['container'] = 'div class=form-group';
     $this->wrappers['control']['container'] = 'div class=col-lg-8';
     $this->wrappers['label']['container'] = 'label class=col-lg-4';
     // make form and controls compatible with Twitter Bootstrap
     $form->getElementPrototype()->class('form-horizontal');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = true;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
Пример #7
0
 public function renderControl(Nette\Forms\IControl $control)
 {
     $this->controlsInit();
     return parent::renderControl($control);
 }
 public function render(Nette\Forms\Form $form, $mode = NULL)
 {
     $this->setupDefaultClasses($form);
     return parent::render($form, $mode);
 }
Пример #9
0
 /**
  * Provides complete form rendering.
  * @param Form $form
  * @return string
  */
 function render(Form $form)
 {
     $this->beforeRender($form);
     return parent::render($form);
 }
Пример #10
0
 public function renderControl(Nette\Forms\IControl $control)
 {
     $this->controlsInit();
     if ($control instanceof Nette\Forms\Controls\UploadControl) {
         return $this->renderUploadControl($control);
     }
     return parent::renderControl($control);
 }
Пример #11
0
 /**
  * Renders 'control' part of visual row of controls.
  * @param \Nette\Forms\IControl $control
  * @return string
  */
 public function renderControl(\Nette\Forms\IControl $control)
 {
     if ($control instanceof \Nette\Forms\Controls\Checkbox) {
         $html = $control->getLabelPrototype();
         $caption = $html->getText();
         $html->setHtml((string) $control->getControl() . " " . $caption);
         return (string) $html;
     }
     return parent::renderControl($control);
 }