Fix bugs in server side custom field validation

- Multiselects were always passing required check
- Validation errors were not properly set, so weren't displayed
This commit is contained in:
Nathan Gray 2014-04-02 20:12:52 +00:00
parent 9c9b784c0c
commit d81adb1d82

View File

@ -316,10 +316,9 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
// run validation method of widget implementing this custom field
$widget = $this->_widget($fname, $field_settings);
$widget->validate($cname, $expand, $content, $validated);
if ((string)$value === '' && $field_settings['needed'])
if ($field_settings['needed'] && (is_array($value) ? !$value : (string)$value === ''))
{
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
self::set_validation_error($field,lang('Field must not be empty !!!'),'');
}
$valid =& self::get_array($validated, $this->id ? $form_name : $field, true);