Yii Framework 2.0 Rules Date Validator

后端 未结 5 2155
情书的邮戳
情书的邮戳 2021-02-19 03:50

I am using Yii Framework 2.0. I have a form with a text input field which is meant for a date. I have read the Yii Framework 2.0 about the Class yii\\validators\\Validat

5条回答
  •  长发绾君心
    2021-02-19 04:29

    Firstly, date validation relies on $model->validate(), so does not work inline but is only triggered by clicking Save (i.e. it's typically applied in actionCreate/actionUpdate).

    Secondly, it's applied after other rules like 'required', and only if they pass, so even when you click Save, if anything else fails validation, those errors will show, but the date error will not.

    In summary, date validation can only be tested by ensuring that all other rules pass and then clicking Save.

提交回复
热议问题