public function validateInput()
 {
     foreach ($this->parameters as $parameter) {
         if (!$parameter->isValidComparison()) {
             $this->addError(Yii::t('modules/parameters', '{comparisonType} is not a valid comparison type for {parameterDisplayName}', ['comparisonType' => Comparison::getComparisonLabel($parameter->getComparison()), 'parameterDisplayName' => $parameter->getDisplayName()]));
         }
         if (!$parameter->isRequiredFulfilled()) {
             $this->addError(Yii::t('modules/parameters', '{parameterDisplayName} is required', ['parameterDisplayName' => $parameter->getDisplayName()]));
         } elseif (!$parameter->isValidValue()) {
             $this->addError(Yii::t('modules/parameters', '{value} is not a valid value for {parameterDisplayName}', ['value' => implode(',', $parameter->getFormattedValue()), 'parameterDisplayName' => $parameter->getDisplayName()]));
         }
     }
     return !$this->hasErrors();
 }
 protected function getParameterWidgetOptions()
 {
     $options = [];
     $options['ajaxSettings']['url'] = Url::to($this->url);
     $options['ajaxSettings']['type'] = $this->ajaxRequestType;
     $options['autoRun'] = $this->autoRun;
     $options['autoShow'] = $this->autoShow;
     $options['reloadPage'] = $this->reloadPage;
     $options['collapseOnRun'] = $this->collapseOnRun;
     $options['comparisons'] = Comparison::getComparisonList();
     $options['types'] = Type::getTypeList();
     $options['loaderElement'] = '#' . $this->loadingWidgetID;
     $options['language'] = $this->getLanguageStrings();
     foreach ($this->parameters as $parameter) {
         /** @var Parameter $parameter */
         if ($parameter->getKey() !== null) {
             $options['parameters'][$parameter->getKey()] = $parameter->getJsObject();
         } else {
             $options['parameters'][] = $parameter->getJsObject();
         }
     }
     return Json::htmlEncode($options);
 }
Ejemplo n.º 3
0
 public function isRequiredFulfilled()
 {
     if (!$this->getIsRequired()) {
         return true;
     }
     $comparisonValueType = Comparison::getComparisonValueType($this->getComparison());
     if (Comparison::VALUE_NONE == $comparisonValueType) {
         $notEmpty = true;
     } elseif (Comparison::VALUE_NORMAL == $comparisonValueType) {
         $notEmpty = isset($this->getValue()[0]) && $this->getValue()[0] !== null && $this->getValue()[0] !== '';
     } elseif (Comparison::VALUE_DOUBLE == $comparisonValueType) {
         $notEmpty = isset($this->getValue()[0]) && $this->getValue()[0] !== null && $this->getValue()[0] !== '' && isset($this->getValue()[1]) && $this->getValue()[1] !== null && $this->getValue()[1] !== '';
     } elseif (Comparison::VALUE_MULTIPLE == $comparisonValueType) {
         $notEmpty = !empty($this->getValue());
     } else {
         $notEmpty = true;
     }
     return $notEmpty && $this->getHasInput();
 }