diff --git a/plugins/format/address-optional.inc b/plugins/format/address-optional.inc new file mode 100644 index 0000000..4cde489 --- /dev/null +++ b/plugins/format/address-optional.inc @@ -0,0 +1,27 @@ + t('Make all address fields optional (Not recommended)'), + 'format callback' => 'addressfield_format_address_optional', + 'type' => 'address', + 'weight' => -11, +); + +/** + * Format callback. + * + * @see CALLBACK_addressfield_format_callback() + */ +function addressfield_format_address_optional(&$format, $address, $context = array()) { + $format['street_block']['thoroughfare']['#required'] = FALSE; + $format['locality_block']['postal_code']['#required'] = FALSE; + $format['locality_block']['dependent_locality']['#required'] = FALSE; + $format['locality_block']['locality']['#required'] = FALSE; + $format['locality_block']['administrative_area']['#required'] = FALSE; +}