If I have the Location cck field as "Required" it still lets me submit the page without inputting an address.

CommentFileSizeAuthor
#11 screenshot 1.png94.16 KBjdidelet
#11 screenshot 2.png24.72 KBjdidelet

Comments

steveadamo’s picture

I have two content types, utulizing the Location module. One form (all fields set to required) is working perfectly. The other form (with a mix of required and non required) isnt requiring any of the flagged fields (nor is it showing the required designation *).

yesct’s picture

Issue tags: +location cck

Tagging.

steveadamo’s picture

So it would seem that if you set the minimum number of locations (under Locative Information > Number of Locations), then the fields you have set as required on the form will indeed be required.

fletch11’s picture

I don't think this is the case. If you vary the the number of locations and the fields set as required in the content type form this does not affect whether fields are required or not in location cck fields, but I could be wrong. This appears to be a bug in the location_cck module.

hefox’s picture

One issue is cordinate chooser does not honor it's required status

Haven't tested it but changed mine here:

     if ($fsettings['locpick']['collect'] == 2) $req = 1; // here 
    $element['locpick']['user_latitude'] = array(
      '#type' => 'textfield',
      '#title' => t('Latitude'),
      '#default_value' => isset($element['#default_value']['locpick']['user_latitude']) ? $element['#default_value']['locpick']['user_latitude'] : '',
      '#size' => 16,
      '#attributes' => array('class' => 'container-inline'),
      '#maxlength' => 20,
      '#required'=>$req,// here
      
    );
    $element['locpick']['user_longitude'] = array(
      '#type' => 'textfield',
      '#title' => t('Longitude'),
      '#default_value' => isset($element['#default_value']['locpick']['user_longitude']) ? $element['#default_value']['locpick']['user_longitude'] : '',
      '#size' => 16,
      '#maxlength' => 20,
      '#required'=>$req, // here

Relucant to make a patch because it's inelegant coding. I assume collect == 2 has a define associated with it right?

deviantintegral’s picture

Required fields are working fine for me in the latest -dev release, with a mix of required / not required fields. Note that I had to make the entire CCK field marked as "required" for it to work.

yesct’s picture

Status: Active » Fixed
jdidelet’s picture

Status: Fixed » Active

Hi,

Sorry I have the last dev version (of 11 July 2010) and it's not working.

yesct’s picture

jdidelet, Please expand on "not working"; tell us what you expected to happen and what actually happened. Please give us step by step instructions for reproducing the problem. Thanks.

yesct’s picture

Status: Active » Postponed (maintainer needs more info)
jdidelet’s picture

StatusFileSize
new24.72 KB
new94.16 KB

I sent you 2 screenshots. I have a content type with location cck field who is required but when I create this content without location information, no error message appear.

deviantintegral’s picture

Try setting one of the Location fields as "Required" instead of "Allow".

Regardless, it looks like the UI for that form could use some attention.

jdidelet’s picture

Ah yes you're right. The cck "Required" is not working but the required inside location cck field is working. Thanks !

kristen pol’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Closed (fixed)

I took the liberty of changing this to a support request and marking fixed.

Also, for those who need it, I figured out how to set this in php as well which I needed because several of my content types share the same location CCK field and the address fields are only required on some of these content types. I had a hard time finding this type of code anywhere though maybe it is out there somewhere!

    $form['field_address'][0]['#required'] = TRUE;
    $form['field_address'][0]['#location_settings']['form']['fields']['street']['collect'] = 2; // required
    $form['field_address'][0]['#location_settings']['form']['fields']['additional']['collect'] = 2; // optional
    $form['field_address'][0]['#location_settings']['form']['fields']['city']['collect'] = 2; // required
    $form['field_address'][0]['#location_settings']['form']['fields']['province']['collect'] = 2; // required
    $form['field_address'][0]['#location_settings']['form']['fields']['postal_code']['collect'] = 2; // required
    $form['field_address'][0]['#location_settings']['form']['fields']['country']['collect'] = 2; // required

Kristen

2ndmile’s picture

#3 fixed it for me.