Closed (fixed)
Project:
Flexinode
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Feb 2006 at 15:09 UTC
Updated:
7 Mar 2006 at 19:30 UTC
When I set a timestamp field as required I can't save posts, I just get the message "You must fill in the field 'Datum'." ("Datum" is Swedish for "Date".) If I uncheck "Required", everything seems to be ok.
Comments
Comment #1
karens commentedI can replicate the problem, but it turns out to be a simple change. The date field returns a different sort of value than other fields do, so it is failing the test used for other fields (the date has six components -- year, month, etc. while other fields only have one component). When you look at it closer, it really doesn't make sense to make a date field required or to check whether it has a value since it has a value by default from the drop-down boxes. If it were to make it into the form anyway, it is then run through a validation to make sure it is a valid date (you can't have a blank date field) so it will have a value by then. Anyway, a date field really doesn't need the test that is causing this error.
It just needs a one-line fix. Just add && $field->field_type != 'timestamp' to the following function, as shown below:
function flexinode_validate($node) {
node_validate_title($node);
if (isset($node->ctype_id)) {
$ctype = flexinode_load_content_type($node->ctype_id);
foreach ($ctype->fields as $field) {
$fieldname = 'flexinode_'. $field->field_id;
$validation = flexinode_invoke('validate', $field, $node);
if ($field->required && !$node->$fieldname && $field->field_type != 'timestamp') {
form_set_error($fieldname, t('You must fill in the field "'. $field->label .'".'));
}
}
}
}
Comment #2
karens commentedSince this is just a one-line change, I incorporated it into my patch at http://drupal.org/node/49279 and I am changing the status of this post.
Comment #3
(not verified) commented