Custom Validation Not Working- Yii2-app-basic-Yii2

前端 未结 5 2367
借酒劲吻你
借酒劲吻你 2021-01-20 09:48

I Posted one question yesterday regarding custom validation for radio button Textfield Mandatory On Radio Button. I got answer. But, that was not exact answer. But, it solve

5条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 10:12

    If you call error without options you supress error output

    ActiveField error method

    yii\widgets\ActiveField

    public function error($options = [])
    {
        if ($options === false) {
            $this->parts['{error}'] = '';
            return $this;
        }
        $options = array_merge($this->errorOptions, $options);
        $this->parts['{error}'] = Html::error($this->model, $this->attribute, $options);
    
        return $this;
    }
    

    Your have to remove call error method into VIEW

    field($model, 'CompanyName')->label('Company Name')->textInput() ?>
    

提交回复
热议问题