I just found out that I mismanaged the submission of empty fields. 😟
Case study:
[list]
Since field1 is empty it is not posted and saved in the database.
field1 has still the value entered when the user created the record.
What is the best way to manage properly that?
A custom server side validation action where I check if the field is set and if not I set it to a an empty value?
if(!isset($form->data['field1']))
$form->data['field1'] = '';
Is there another CF way?
Thank you
maxx
p.s. What I described above doesn't happen for any text box element. It happens for fields that are required depending on a drop down selected value.
In my form there's some js code that manages that:
if(e.target.options[e.target.selectedIndex].value=='other')
{
$(target).set('disabled',false);
$(target).addClass("validate['required']");
formCheck_myform.register($(target));
} else {
$(target).set('disabled',true);
$(target).set('value','');
$(target).removeClass("validate\\['required'\\]");
formCheck_myform.dispose($(target));
}
(target is the id of field1)
The dropdown element has a list of presets and an "other" value. If the user wants to enter a value other than the presets, he selects "other" and field1 gets enabled and becomes required.
If the user selects a value other than "other", field1 is disabled and becomes not required.