I have a form in cfwheels. I am using model which automatically detect if the field is empty.
View:
#startFormTag(action="t_validate")#
<div>
#textField(label="Supervisor Name:", objectName="supervisor", property="name")#
#errorMessageOn(objectName="supervisor", property="name")#
</div>
<div>
#textField(label="Inspector Name:", objectName="inspector", property="name")#
#errorMessageOn(objectName="inspector", property="name")#
</div>
#submitTag()#
#endFormTag()#
Controller Action:
public function t_validate()
{
title = "Complete";
supervisor = model("supervisors").new();
inspector = model("inspectors").new();
if(isPost() and StructKeyExists(params, "inspector"))
{
supervisor = model("tb_mchn_supervisors").new(params.supervisor);
supervisor.save();
inspector = model("tb_mchn_inspectors").new(params.inspector);
inspector.save();
}
}
So Supervisor has a column named "NAME" and inspector has a column named "NAME". Is there a way to modify the default column error messages. Right now, it show as "NAME can't be empty" for both fields. Perhaps something like "supervisor name is empty or inspector name is empty" would be better.
You can define custom Validation Messages in the model files with for example validatesPresenceOf() and the message Parameter.