Doesn't work with Country, ZIP, State disabled

augustofagioli - March 13, 2008 - 10:40
Project:Address field for CCK
Version:5.x-2.1
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

For some reason I have to get cck_address with:
- Address
- Address continued
-Apt/suite number
fields only (i don't want city, country, zip info here )

After submitting the form, the disabled fields are still required by Drupal

these few line in the form_alter of the extension language will solve this issue

function cck_address_afganistan_form_alter($form_id, &$form) {
  //we don't want the city field  as required
  if ($form_id=='supplier_node_form' )  {
    $form['field_supplier_main_address'][0]['city']['#required']=0;
  }
}

Hope this helps

http://www.fagioli.biz

#1

rconstantine - March 15, 2008 - 19:05
Category:bug report» support request

I just tried it and had no problems at all. A screenshot of your settings would be nice.

#2

augustofagioli - March 16, 2008 - 16:00

rconstantine, thanks for your answer!

please see attached screenshots

below, export of the dummy content type:

$content[type]  = array (
  'name' => 'dummy',
  'type' => 'dummy',
  'description' => '',
  'title_label' => 'Title',
  'body_label' => 'Body',
  'min_word_count' => '0',
  'help' => '',
  'node_options' =>
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'comment' => '2',
  'upload' => '1',
  'image_attach' => '0',
  'image_attach_size_teaser' => 'thumbnail',
  'image_attach_weight_teaser' => '0',
  'image_attach_size_body' => 'thumbnail',
  'image_attach_weight_body' => '0',
  'old_type' => 'dummy',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
  'ant' => '0',
  'ant_pattern' => '',
  'auto_nodetitle_php' => 0,
);
$content[fields]  = array (
  0 =>
  array (
    'widget_type' => 'cck_address',
    'label' => 'address (no country)',
    'weight' => '0',
    'description' => '',
    'group' => false,
    'required' => '1',
    'multiple' => '',
    'state_abbrv' => '0',
    'country_abbrv' => 0,
    'other_countries' => 0,
    'clist' =>
    array (
      'US' => true,
      0 => 1,
      'AF' => false,
      'CA' => false,
    ),
    'fielddisplay' =>
    array (
      'field_display_street1' => true,
      'field_display_street2' => true,
      'field_display_apt' => true,
      'field_display_city' => false,
      'field_display_state' => false,
      'field_display_zip' => false,
      'field_display_country' => false,
      'field_display_other' => false,
    ),
    'max_length_street1' => '',
    'max_length_street2' => '',
    'max_length_apt' => '',
    'max_length_city' => '',
    'max_length_other' => '',
    'field_names_street1' => 'Address',
    'field_names_street2' => 'Address continued',
    'field_names_apt' => 'Apt/suite number',
    'field_names_city' => 'City',
    'field_names_state' => 'State',
    'field_names_zip' => 'ZIP',
    'field_names_country' => 'Country',
    'field_names_other' => 'Other',
    'field_order' =>
    array (
      'street1' => '1',
      'street2' => '2',
      'apt' => '3',
      'city' => '4',
      'state' => '5',
      'zip' => '6',
      'country' => '7',
      'other' => '8',
    ),
    'field_defaults_street1' => '',
    'field_defaults_street2' => '',
    'field_defaults_apt' => '',
    'field_defaults_city' => '',
    'field_defaults_state' => 'bag',
    'field_defaults_zip' => '',
    'field_defaults_country' => 'AF',
    'field_defaults_other' => '',
    'field_name' => 'field_address_no_country',
    'field_type' => 'cck_address',
    'module' => 'cck_address',
  ),
);

AttachmentSize
snapshot19.png 27.35 KB
snapshot20.png 16.56 KB

#3

kenorb - March 20, 2008 - 09:25

I have similar problem with custom multi-select cck widgets and checkboxes.

#4

jonathan_hunt - May 14, 2008 - 22:53

I get the same issue for New Zealand addresses that don't require State. I've disabled State via the CCK Address UI, but it still is marked as required in the node_form edit array. The work around is as above (override required status using form_alter).

 
 

Drupal is a registered trademark of Dries Buytaert.