配送を有効にしていると、なにする件の修正です :|
function yourtheme_address_pane($form) {
drupal_set_html_head('<script src="'. check_url(url('http://ajaxzip3.googlecode.com/svn/trunk/ajaxzip3/ajaxzip3.js')) .'" type="text/javascript"></script>');
$req = '<span class="form-required">*</span>';
if (isset($form['copy_address'])) {
$output .= drupal_render($form['copy_address']);
}
$output .= '<div class="address-pane-table"><table>';
$fields = element_children($form);
if ($form['#parents'][1] == 'delivery') {
$pane_type = 'delivery';
}
else {
$pane_type = 'billing';
}
$sorted = array_map(
create_function('$a', "return $pane_type . '_'. \$a;"),
array('address_select', 'last_name', 'first_name', 'company', 'postal_code', 'country', 'zone', 'city', 'street1', 'street2', 'phone')
);
$fields = array_intersect($sorted, $fields);
$postal = $pane_type .'_postal_code';
if (!is_array($form[$postal]['#attributes'])) {
$form[$postal]['#attributes'] = array();
}
$form[$postal]['#attributes'] = array_merge(
$form[$postal]['#attributes'],
array('onKeyUp' => "AjaxZip3.zip2addr(\"panes[{$pane_type}][{$pane_type}_postal_code]\", \"\", \"panes[{$pane_type}][{$pane_type}_zone]\", \"panes[{$pane_type}][{$pane_type}_city]\", \"panes[{$pane_type}][{$pane_type}_street1]\");")
);
foreach ($fields as $field) {
if (in_array($field, $sorted)) {
$title = $form[$field]['#title'] .':';
unset($form[$field]['#title']);
if (substr($field, -7) == 'street1') {
$title = uc_get_field_name('street') .':';
}
elseif (substr($field, -7) == 'street2') {
$title = ' ';
}
$output .= '<tr><td class="field-label">';
if ($form[$field]['#required']) {
$output .= $req;
}
$output .= $title .'</td><td>'. drupal_render($form[$field]) .'</td></tr>';
}
}
$output .= '</table></div>';
foreach ($fields as $element) {
$output .= drupal_render($form[$element]);
}
return $output;
}
しかしこういうのって、Drupal 7のentity使うことでこういう事しなくても良くなったりしないのかなー
しかも久々の更新ですね。はい。
追記
あ
if ($form['#parents'][1] == 'delivery') {
$pane_type = 'delivery';
}
else {
$pane_type = 'billing';
}
って
$pane_type = $form['#parents'][1];
で、いいやん・・
そんなぐだぐだな、肌寒い夜。