getClientOptions() protected method

Returns the client-side validation options.
protected getClientOptions ( Model $model, string $attribute ) : array
$model yii\base\Model the model being validated
$attribute string the attribute name being validated
return array the client-side validation options
Esempio n. 1
0
 /**
  * @inheritdoc
  */
 protected function getClientOptions($model, $attribute)
 {
     $options = parent::getClientOptions($model, $attribute);
     $label = $model->getAttributeLabel($attribute);
     if ($this->notImage !== null) {
         $options['notImage'] = Yii::$app->getI18n()->format($this->notImage, ['attribute' => $label], Yii::$app->language);
     }
     if ($this->minWidth !== null) {
         $options['minWidth'] = $this->minWidth;
         $options['underWidth'] = Yii::$app->getI18n()->format($this->underWidth, ['attribute' => $label, 'limit' => $this->minWidth], Yii::$app->language);
     }
     if ($this->maxWidth !== null) {
         $options['maxWidth'] = $this->maxWidth;
         $options['overWidth'] = Yii::$app->getI18n()->format($this->overWidth, ['attribute' => $label, 'limit' => $this->maxWidth], Yii::$app->language);
     }
     if ($this->minHeight !== null) {
         $options['minHeight'] = $this->minHeight;
         $options['underHeight'] = Yii::$app->getI18n()->format($this->underHeight, ['attribute' => $label, 'limit' => $this->minHeight], Yii::$app->language);
     }
     if ($this->maxHeight !== null) {
         $options['maxHeight'] = $this->maxHeight;
         $options['overHeight'] = Yii::$app->getI18n()->format($this->overHeight, ['attribute' => $label, 'limit' => $this->maxHeight], Yii::$app->language);
     }
     return $options;
 }
 /**
  * @inheritdoc
  */
 protected function getClientOptions($model, $attribute)
 {
     $options = parent::getClientOptions($model, $attribute);
     $label = $model->getAttributeLabel($attribute);
     if ($this->minDimension !== null) {
         $options['minDimension'] = $this->minDimension;
         $options['underDimension'] = Yii::$app->getI18n()->format($this->underDimension, ['attribute' => $label, 'limit' => $this->minDimension], Yii::$app->language);
     }
     if ($this->maxDimension !== null) {
         $options['maxDimension'] = $this->maxDimension;
         $options['overDimension'] = Yii::$app->getI18n()->format($this->overDimension, ['attribute' => $label, 'limit' => $this->maxDimension], Yii::$app->language);
     }
     return $options;
 }