当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseControl::setOption方法代码示例

本文整理汇总了PHP中Nette\Forms\Controls\BaseControl::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseControl::setOption方法的具体用法?PHP BaseControl::setOption怎么用?PHP BaseControl::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Forms\Controls\BaseControl的用法示例。


在下文中一共展示了BaseControl::setOption方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareControl

 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-envelope"'));
     }
     if ($control->controlPrototype->type === 'password' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-lock"'));
     }
     if ($control instanceof \Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     } else {
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('form-group');
         $label = $control->labelPrototype;
         if (static::isCheckbox($control)) {
             $label->addClass('checkbox');
         } elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
             $label->addClass('control-label');
             if (!$control instanceof \Minetro\Forms\reCAPTCHA\ReCaptchaField) {
                 $el->addClass('form-control');
             }
         }
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('has-error');
         }
         if ($prepend = $control->getOption('input-prepend')) {
             $prepend = Html::el('span', array('class' => 'input-group-addon'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
             $control->setOption('input-prepend', $prepend);
         }
         if ($append = $control->getOption('input-append')) {
             $append = Html::el('span', array('class' => 'input-group-addon'))->{$append instanceof Html ? 'add' : 'setText'}($append);
             $control->setOption('input-append', $append);
         }
     }
 }
开发者ID:josefzajac,项目名称:BootstrapFormRenderer,代码行数:55,代码来源:BootstrapRenderer.php

示例2: prepareControl

 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', '@');
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     } else {
         $label = $control->labelPrototype;
         if ($control instanceof Controls\Checkbox) {
             $label->addClass('checkbox');
         } elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
             $label->addClass('control-label');
         }
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('control-group');
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('error');
         }
         if ($prepend = $control->getOption('input-prepend')) {
             $prepend = Html::el('span', array('class' => 'add-on'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
             $control->setOption('input-prepend', $prepend);
         }
         if ($append = $control->getOption('input-append')) {
             $append = Html::el('span', array('class' => 'add-on'))->{$append instanceof Html ? 'add' : 'setText'}($append);
             $control->setOption('input-append', $append);
         }
     }
 }
开发者ID:sasule,项目名称:BootstrapFormRenderer,代码行数:49,代码来源:BootstrapRenderer.php

示例3: prepareControl

 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', '@');
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
         if ($control->getOption('btn-class') !== NULL) {
             $el->addClass($control->getOption('btn-class'));
         } else {
             $el->addClass('btn-default');
         }
     } else {
         if (static::isTextBase($control) || $control instanceof Controls\SelectBox) {
             $classes = $control->controlPrototype->class;
             if (!is_array($classes)) {
                 $classes = explode(' ', $classes);
             }
             if (($pos = array_search('no-form-control', $classes, TRUE)) !== FALSE) {
                 unset($classes[$pos]);
                 $el->class = $classes;
             } elseif ($control->getOption('noFormControl', FALSE) !== TRUE) {
                 $el->addClass('form-control');
             }
         }
         $label = $control->labelPrototype;
         if (!$control instanceof Controls\Checkbox && !$control instanceof Controls\RadioList && !static::isCheckboxList($control)) {
             $label->addClass('control-label');
         }
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('form-group');
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('has-error');
         }
     }
 }
开发者ID:honzaskovran,项目名称:bootstrap3renderer,代码行数:56,代码来源:BootstrapRenderer.php

示例4: setOption

 /**
  * @param $key
  * @param $value
  * @return BaseControl
  */
 public function setOption($key, $value)
 {
     return $this->wrappedControl->setOption($key, $value);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:9,代码来源:ApplyButtonWrapper.php

示例5: prepareControl

 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
     }
     $el = $control->getControlPrototype();
     if ($el->getName() === 'input') {
         $el->class(strtr($el->type, array('password' => 'text', 'file' => 'text', 'submit' => 'button', 'image' => 'imagebutton')), TRUE);
     }
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email') {
         $email = Html::el('span', array('class' => 'add-on'))->setText('@');
         $control->setOption('input-prepend', $email);
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     }
 }
开发者ID:rostenkowski,项目名称:nette-forms-renderer,代码行数:28,代码来源:BootstrapRenderer.php


注:本文中的Nette\Forms\Controls\BaseControl::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。