我想使用表单API drupal发送我的表单值。我有以下价值
$form['billing']["cardholders_name"] = array(
'#type' => 'textfield',
'#title' => t("Cardholder's Name"),
'#required' => TRUE,
'#prefix' => '<div class="field-wrapper-w1 card-name">'
);
我在表单提交功能中编写以下代码
function test_form_submit($form, &$form_state) {
$form_state['redirect'] = 'www.test.com/page' . '?cname=' . $form_state['values']['billing[cardholders_name]'];
}
但它似乎无法正常工作。请帮忙
答案 0 :(得分:0)
以下示例显示在
中http://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_redirect_form/7
$form_state['redirect'] = array(
'node/123',
array(
'query' => array(
'foo' => 'bar',
),
'fragment' => 'baz',
),
);
答案 1 :(得分:0)
表单元素的任何值都在$ form_state的值下,所以在你的函数test_form_submit中你可以访问cardholders_name
$form_state['values']['cardholders_name']
你也可以用drupal_goto()
这样做 drupal_goto('www.test.com/page' . '?cname=' . $form_state['values']['cardholders_name]);