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


PHP Controls\BaseControl类代码示例

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


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

示例10: __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

示例11: __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

示例12: __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

示例13: __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

示例14: __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

示例15: __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


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