當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。