dpm($form) が機能しました。良い!これは、データを表示するためのはるかに優れた方法です。私はまだ、場所の経度と緯度など、どこからのものかを把握しようとしています。「経度」という言葉は 20 か所で参照されています。これは、この入力フィールドのテキスト ボックスを分離する可能性が高い場所だと思いました。dpm($form['#field_info']['field_store_latitude']['location_settings']['form']['fields']);
個々の入力要素を追跡する方法に関するヒントはありますか?
**これは答えではありませんが、私の最初の質問に対する補足です**
こんにちは googletorp -
hook_form_alter を使用して既存のフォームを変更しようとしています。
数時間探し回った後、次のようなフォームの場所 (経度/緯度) セクションをオフにできるようになりました。
unset($form['field_store_latitude']);
ただし、このように緯度だけをオフにすることはできません:
unset($form['field_store_latitude']['0']['#location_settings']['form']['fields']['locpick']) ;
Krumo によって生成された配列を使用して、html ソースの ID と名前を簡単にリンクする方法が見つかりません。この場合、id は「edit-field-store-latitude-0-locpick-user-latitude」と呼ばれます。
Drupal フォームでフォーム要素を識別するためのレシピまたはガイドラインが必要です。
私は解決策を突き止めたと思う
<?php
// allows you to alter locations fields, which are tricky to access.
// this will require a patch in location module described here:
// http://drupal.org/node/381458#comment-1287362
/**
* Implementation of custom _element_alert() hook.
*/
function form_overrides_location_element_alter(&$element){
// change some location descriptions
$element['locpick']['user_latitude']['#description'] = ' ' . t('Use decimal notation.');
$element['locpick']['user_longitude']['#description'] = ' ' . t('See <a href=!url target=_blank>our help page</a> for more information.', array('!url' => url('latlon_help')));
// or make them disappear entirely
unset($element['locpick']['user_longitude']);
unset($element['locpick']['user_latitude']);
}
/**
* Implementation of form_alter hook.
*/
function form_overrides_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_profile_form':
// change titles in user profile form
$form['account']['name']['#title'] = t('Login Name');
$form['account']['mail']['#title'] = t('Email');
break;
case 'retailer_node_form':
// let's check what is supposed to be here...
print '<pre>';
//print_r($form);
dsm($form);
print '</pre>';
// this works to remove the city
unset($form['field_myvar_latitude']['0']['#location_settings']['form']['fields']['city']);
// let's try #after_build property
$form['#after_build'][]='mymodule_after_build_mynode';
break;
}
}
function mymodule_after_build_mynode($form, $form_values) {
// This will not work for locations fields
return $form;
}`enter code here`