hello dears
i have form , on submit the model validate is always return false although the rules function is empty
public function rules()
{
return array(
);
}
any help please
hello dears
i have form , on submit the model validate is always return false although the rules function is empty
public function rules()
{
return array(
);
}
any help please
Hi @haithamedrees23,
You have to define the rules.
Validation returns false because the rules are empty.
@softark thanks for your answer
but even if i defined a rules still there is a problem
for example if i defined some attributes as ‘safe’ then on submit the inputs are reuired
also if i try to print something in the rules function of the model or rules function of the CModel class , its not printed , meaning that the rules function is not called
Remove everything you added to the rules function(s), not approved by the docs, and try again. Not executable code.
@tri , sorry but i didn’t get what you mean
there are no rules in the rules function (the array is empty)
Just the array, that’s my point.
Edit:
Never mind, as long as you return the array it should work.
I just checked that no fields are required if the array is left empty in an old 1.1 Contact form.
More info:
https://www.yiiframework.com/doc/api/1.1/CModel#validate-detail
If you use beforeValidate(), remember to return true.
Still no explanation why you get fields required without rules.
Is an empty array OK for “rules”? I didn’t know that.
@haithamedrees23 anyway, there’s too few information to tell what is wrong. Could you post the relevant code?