Nette\Forms\Rendering\DefaultFormRenderer::renderControl PHP Method

renderControl() public method

Renders 'control' part of visual row of controls.
public renderControl ( Nette\Forms\IControl $control ) : string
$control Nette\Forms\IControl
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 IHtmlString) {
            $description = ' ' . $description;
        } elseif (is_string($description)) {
            if ($control instanceof Nette\Forms\Controls\BaseControl) {
                $description = $control->translate($description);
            }
            $description = ' ' . $this->getWrapper('control description')->setText($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));
    }

Usage Example

Example #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;
 }
All Usage Examples Of Nette\Forms\Rendering\DefaultFormRenderer::renderControl