我让 dpm($form) 工作。好的!这是查看数据的更好方法。我仍在试图弄清楚东西的来源,例如:位置经度和纬度。“经度”这个词在 20 个不同的地方被引用。我认为这可能是隔离此输入字段的文本框的地方。dpm($form['#field_info']['field_store_latitude']['location_settings']['form']['fields']);
关于如何追踪单个输入元素的任何提示?
**这不是答案,而是对我的第一个问题的补充**
嗨 googletorp -
我正在尝试使用 hook_form_alter 修改现有表单。
经过几个小时的闲逛,我现在可以关闭表单的位置(经度/纬度)部分,如下所示:
未设置($form['field_store_latitude']);
但是,像这样关闭纬度不起作用:
unset($form['field_store_latitude']['0']['#location_settings']['form']['fields']['locpick']) ;
我找不到一种简单的方法来将 html 源代码中的 id 和名称与 Krumo 生成的数组链接起来。在这种情况下,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`