• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Controls\BaseControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: save

 /**
  * @param object         $object
  * @param string         $fieldName
  * @param BaseControl    $control
  * @param IClassMetadata $classMetadata
  * @throws \NForms\Exceptions\UnexpectedTypeException
  * @return bool
  */
 public function save($object, $fieldName, BaseControl $control, IClassMetadata $classMetadata)
 {
     if ($control->isOmitted() || $control->isDisabled()) {
         return TRUE;
     }
     $value = $control->getValue();
     if ($classMetadata->hasAssociation($fieldName) && $value !== NULL) {
         if ($classMetadata->isSingleValuedAssociation($fieldName)) {
             $value = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $value);
         } else {
             if (!is_array($value) && (!$value instanceof \ArrayAccess || !$value instanceof \Iterator)) {
                 throw new UnexpectedTypeException("In mapping association {$classMetadata->getClass()}::\${$fieldName} - expected array or ArrayAccess and Iterator instance, given " . get_class($value) . ".");
             }
             $collection = array();
             foreach ($value as $id) {
                 $collection[] = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $id);
             }
             $value = $collection;
         }
     }
     if ($classMetadata->hasAssociation($fieldName)) {
         $classMetadata->setAssociationValue($object, $fieldName, $value);
     } else {
         if ($control instanceof Nette\Forms\Controls\TextBase && $value === '') {
             $value = NULL;
         }
         $classMetadata->setFieldValue($object, $fieldName, $value);
     }
     return TRUE;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:38,代码来源:ControlMapper.php


示例2: toPropertyValue

 public function toPropertyValue(\Nette\Forms\Controls\BaseControl $control, Builder\Metadata $metadata)
 {
     $value = $control->getValue();
     if ($value !== null) {
         $value = $metadata->type === 'float' ? (double) $value : (int) $value;
     }
     return $value;
 }
开发者ID:voda,项目名称:formbuilder,代码行数:8,代码来源:NumberMapper.php


示例3: label

 public static function label(Html $label, BaseControl $control, $isPart)
 {
     if ($label->getName() === 'label') {
         $label->addClass('control-label');
     }
     if ($control->isRequired()) {
         $label->addClass('required');
     }
     return $label;
 }
开发者ID:jirinapravnik,项目名称:common,代码行数:10,代码来源:Bootstrap3InputMacros.php


示例4: addNominalDiscountControl

 private function addNominalDiscountControl(BaseControl $priceControl)
 {
     $errorMessage = 'Nominal discount must be between 0 and original price.';
     $control = $this->addText('nominalDiscount', 'Nominal discount');
     $control->setType('number')->setAttribute('step', 'any')->setDefaultValue(0)->addRule(self::FLOAT, $errorMessage)->addRule(function (TextInput $input) use($priceControl) {
         return $input->getValue() >= 0 && $input->getValue() < $priceControl->getValue();
     }, $errorMessage);
     if ($this->editedProduct !== null) {
         $control->setDefaultValue($this->editedProduct->getNominalDiscount());
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:11,代码来源:ProductForm.php


示例5: resolveRequiring

 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  * @param string|null $errorMessage
  * @param bool|callable $requiring
  */
 private function resolveRequiring(\Nette\Forms\Controls\BaseControl $control, $errorMessage = null, $requiring = false)
 {
     if ($requiring === true) {
         $control->setRequired($errorMessage !== null ? $errorMessage : true);
     } elseif (is_callable($requiring)) {
         $condition = $requiring($control);
         if (!$condition instanceof \Nette\Forms\Rules) {
             throw new RequiredFormFieldResolutionException('Requiring call must return instance of \\Nette\\Forms\\Rules.');
         }
         $condition->setRequired($errorMessage !== null ? $errorMessage : true);
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:17,代码来源:RequiredFormFieldResolution.php


示例6: getControl

 /**
  * Generates control's HTML element.
  *
  * @return string
  */
 public function getControl()
 {
     $items = $this->getItems();
     reset($items);
     $input = BaseControl::getControl();
     return Helpers::createInputList($this->translate ? $this->translate($items) : $items, array_merge($input->attrs, ['id' => NULL, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'required' => NULL, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']]]), $this->label->attrs, $this->separator);
 }
开发者ID:webchemistry,项目名称:forms-controls,代码行数:12,代码来源:CheckboxList.php


示例7: getControl

 /**
  * Just remove translations from each option
  * @return Nette\Forms\Helpers
  */
 public function getControl()
 {
     $items = $this->prompt === FALSE ? array() : array('' => $this->translate($this->prompt));
     foreach ($this->options as $key => $value) {
         $items[is_array($value) ? $key : $key] = $value;
     }
     return Nette\Forms\Helpers::createSelectBox($items, array('selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL))->addAttributes(BaseControl::getControl()->attrs);
 }
开发者ID:ublaboo,项目名称:controls,代码行数:12,代码来源:NotTranslatableSelectBox.php


示例8: getControl

 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $items = $this->getPrompt() === FALSE ? [] : ['' => $this->translate($this->getPrompt())];
     foreach ($this->options as $key => $value) {
         $items[$this->translate && is_array($value) ? $this->translate($key) : $key] = $this->translate ? $this->translate($value) : $value;
     }
     return Helpers::createSelectBox($items, ['selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL])->addAttributes(BaseControl::getControl()->attrs);
 }
开发者ID:webchemistry,项目名称:forms-controls,代码行数:13,代码来源:SelectBox.php


示例9: getControl

 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $input = BaseControl::getControl();
     $items = $this->getItems();
     $ids = [];
     if ($this->generateId) {
         foreach ($items as $value => $label) {
             $ids[$value] = $input->id . '-' . $value;
         }
     }
     return $this->container->setHtml(Helpers::createInputList($this->translate ? $this->translate($items) : $items, array_merge($input->attrs, ['id:' => $ids, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']]]), ['for:' => $ids] + $this->itemLabel->attrs, $this->separator));
 }
开发者ID:webchemistry,项目名称:forms-controls,代码行数:17,代码来源:RadioList.php


示例10: register

 static function register()
 {
     BaseControl::extensionMethod('addDataFlag', function (BaseControl $that, $name) {
         $that->getControlPrototype()->addAttributes(['data-' . $name => TRUE]);
         return $that;
     });
     BaseControl::extensionMethod('hasDataFlag', function (BaseControl $that, $name) {
         return isset($that->getControlPrototype()->attrs['data-' . $name]);
     });
     BaseControl::extensionMethod('removeDataFlag', function (BaseControl $that, $name) {
         unset($that->getControlPrototype()->attrs['data-' . $name]);
         return $that;
     });
 }
开发者ID:instante,项目名称:ui,代码行数:14,代码来源:FormControlHtmlDecorator.php


示例11: createButton

 public function createButton()
 {
     if ($this->button) {
         return FALSE;
     }
     /** @var Nette\Forms\Container $container */
     $container = $this->control->lookup('Nette\\Forms\\Container');
     $name = $this->control->getName() . self::$buttonSuffix;
     $this->button = new SubmitButton("Apply");
     $this->button->setValidationScope(false);
     $container->addComponent($this->button, $name);
     $this->control->getControlPrototype()->addAttributes(array('data-apply-button' => $this->button->getHtmlId()));
     return TRUE;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:14,代码来源:DependencyHelper.php


示例12: __construct

 public function __construct($caption, $publicKey, $privateKey)
 {
     $this->monitor('Nette\\Forms\\Form');
     parent::__construct($caption);
     $this->publicKey = $publicKey;
     $this->privateKey = $privateKey;
 }
开发者ID:bazo,项目名称:translation-ui,代码行数:7,代码来源:ReCaptcha.php


示例13: __construct

 /**
  * @return ShiftPatternDate
  */
 public function __construct(Template $template, DateTime $date, $templateFileName)
 {
     parent::__construct(null);
     $this->addRule(__CLASS__ . '::validatePattern', 'Shift pattern is invalid.');
     $this->_template = $template;
     $this->_template->setFile(__DIR__ . "/{$templateFileName}");
     $this->_template->registerHelper('dayName', function ($dayNumber) {
         return DateTime::dayName($dayNumber);
     });
     $this->_template->registerHelper('padTime', function ($t) {
         if ($t < 10) {
             return '0' . $t;
         }
         return $t;
     });
     $this->_template->registerHelper('selectOption', function ($timeUnit, $time, $type) {
         $timeUnit = (int) $timeUnit;
         list($hour, $minute) = explode(':', $time);
         $hour = (int) $hour;
         $minute = (int) $minute;
         if ($type === 'h') {
             return $timeUnit === $hour ? 'selected="selected"' : '';
         }
         if ($type === 'm') {
             return $timeUnit === $minute ? 'selected="selected"' : '';
         }
     });
     // returns curren formated date and moves date one day forward
     $this->_template->registerHelper('day', function ($date) {
         $day = $date->format('j F');
         $date->addDay();
         return $day;
     });
     $this->_date = $date;
 }
开发者ID:dansilovsky,项目名称:calendar,代码行数:38,代码来源:PatternInput.php


示例14: __construct

 public function __construct($caption = NULL, $side, $border)
 {
     $this->monitor('Nette\\Forms\\Form');
     parent::__construct($caption);
     $this->side = $side;
     $this->border = $border;
 }
开发者ID:bazo,项目名称:nette-form-controls,代码行数:7,代码来源:ColorPicker.php


示例15: __construct

 public function __construct($caption = NULL, $min, $max)
 {
     $this->monitor('Nette\\Forms\\Form');
     parent::__construct($caption);
     $this->min = $min;
     $this->max = $max;
 }
开发者ID:bazo,项目名称:nette-form-controls,代码行数:7,代码来源:PlusMinus.php


示例16: __construct

 public function __construct($label = null, array $entity = NULL, array $config = NULL)
 {
     parent::__construct($label);
     $this->entity = $entity;
     $this->labelName = $label;
     $this->options = $config;
 }
开发者ID:nechutny,项目名称:form-selectize,代码行数:7,代码来源:Selectize.php


示例17: __construct

 /**
  * @param  ReCaptcha $reCaptcha
  * @param  Http\Request $httpRequest
  * @param  string $caption
  */
 public function __construct(ReCaptcha $reCaptcha, Http\Request $httpRequest, $caption = NULL)
 {
     parent::__construct($caption);
     $this->setOmitted();
     $this->reCaptcha = $reCaptcha;
     $this->httpRequest = $httpRequest;
     $this->control = $reCaptcha->getHtml();
 }
开发者ID:pavelplzak,项目名称:ReCaptchaControl,代码行数:13,代码来源:ReCaptchaControl.php


示例18: getControl

 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $parentControl = parent::getControl();
     $control = $this->getWrapperPrototype();
     $control->addAttributes(['id' => $parentControl->id]);
     $control->setHtml($this->getContent());
     return $control;
 }
开发者ID:minetro,项目名称:forms,代码行数:13,代码来源:Markup.php


示例19: getControl

 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $parentControl = parent::getControl();
     $control = $this->getWrapperPrototype();
     $control->setId($parentControl->getId());
     $control->setHtml($this->getContent());
     return $control;
 }
开发者ID:f3l1x,项目名称:nette-plugins,代码行数:13,代码来源:MarkupControl.php


示例20: updateControlClass

 /**
  * Update html class of control
  */
 protected function updateControlClass()
 {
     if ($this->controlClass !== null) {
         $classes = explode(" ", $this->control->getControlPrototype()->class);
         if (!in_array($this->controlClass, $classes)) {
             $this->control->getControlPrototype()->class($this->controlClass);
         }
     }
 }
开发者ID:bazo,项目名称:dependentselectbox,代码行数:12,代码来源:FormControlDependencyHelper.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Http\IRequest类代码示例发布时间:2022-05-23
下一篇:
PHP Forms\IControl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap