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.

Comments

ceaker’s picture

Sorry, the Email Field version is 6.x-1.1, not version 5 as listed above.

deviantintegral’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.05

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.

deviantintegral’s picture

Version: 6.x-1.05 » 6.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

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 value
  if (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!

deviantintegral’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new552 bytes

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.

recidive’s picture

Status: Needs review » Reviewed & tested by the community

Good catch!

Patch fix the problem.

Not sure if there are any regressions, but this looks ready to go.

brmassa’s picture

Status: Reviewed & tested by the community » Fixed

Guys,

thanks a lot. i just commited the patch on CVS. soon on the next release.

regards,

massa

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.