I need the following validation rules on a form via AJAX:
- The validation of courses only occur if the Dropwn List code is 2, 3, 4.
In this case the Company Name and Address Company fields are required. I tried this code for validation model condition nomeempresa:
This code for Model validate in case tipoincricao_codigo ==2 [['nomeempresa'/*,'cnpj','emailempresa','telefonefixoempresa','telefonecelularempresa', 'enderecoempresa', 'bairroempresa', 'cidadeempresa', 'estadoempresa', 'cepempresa'*/], 'required', 'when' => function ($model) { return $model->tipoinscricao_codigo == 2; }, 'whenClient' => "function (attribute, value) { return $('#tipoinscricao_codigo').val() == 2; }"],
Aucun commentaire:
Enregistrer un commentaire