validation of required fields fails
| Project: | Addresses |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Drupal Core 6.6
Other installed modules:
CCK 6.x-2.1
Contemplate 6.x-1.0
Date 6.x-2.0-rc4
Email Field 5.x-1.1
Token 6.x-1.11
Views 6.x-2.1
I have configured several addresses subfields (in my case, City, Street, Postal Code, and Phone) as 'required' in the CCK node type definition. However, when I create a node of the new type and leave those fields blank, Drupal creates the node just fine. My expectation was that when I submit the node for creation, I would get a error telling me those fields are required. This seems like either a code issue (assuming I'm correct) or documentation help issue (assuming I'm mistaken).
Also, on the create node form, I noticed that these fields did not have the asterisk that normally displays next to required fields.

#1
Sorry, the Email Field version is 6.x-1.1, not version 5 as listed above.
#2
I'm encountering the same issue. This is important as we want to require users to provide a physical address. In my case, we're using the Content Profile module to create profile nodes for users, not the module included with this one.
#3
I've found a fix, if not the underlying issue, and it's in the latest development version as well.
At line 167 in addresses.module:
// Reset the required fields based on the general required valueif (empty($element['#required'])) {
foreach ($fields as $field => $required) {
if ($required == ADDRESSES_FIELD_REQUIRED) {
$fields[$field] = ADDRESSES_FIELD_SHOW;
}
}
}
This seems to be removing the required values from each field. If I comment out line 167, it seems to work as expected. I'm not too sure what the purpose of the code is; I took a look at the annotate logs and the comment wasn't really enlightening.
@brmassa: Is there an issue number which matches with version 1.25 of that file? Based on what I can tell, I think the fix is to remove that whole bit of code, but I'm sure there's something else going on I haven't picked up on yet. Let me know and I'll roll up a patch.
Thanks!
#4
I think I figured out what this was trying to do based on an issue discovered by my above hack. When you comment that line, required fields end up requiring default values on the field configuration form. So here is a patch which lets the fields be required on normal nodes, and demotes them to ADDRESSES_FIELD_SHOW on the field configuration form.
#5
Good catch!
Patch fix the problem.
Not sure if there are any regressions, but this looks ready to go.
#6
Guys,
thanks a lot. i just commited the patch on CVS. soon on the next release.
regards,
massa
#7
Automatically closed -- issue fixed for 2 weeks with no activity.