在Drupal'中访问值;s$form_值来自自定义Drupal表单

在Drupal'中访问值;s$form_值来自自定义Drupal表单,drupal,drupal-6,drupal-forms,Drupal,Drupal 6,Drupal Forms,编辑:似乎我的“数组爬行”技能还不够,谢谢你的建议。 此外,我发现我正在用一个普通的“=”而不是一个双精度的“=”检查$discounttype条件。我猜在同一块代码上敲上3个小时会让你哑口无言,错过最明显的错误 首先,我在Drupal 6上 我已使用以下标记创建了一个表单: $form["cart_".$index] = array( '#type' => 'image_button', '#src'=> 'files/imghome/sidebar-add-demo.gif',

编辑:似乎我的“数组爬行”技能还不够,谢谢你的建议。 此外,我发现我正在用一个普通的“=”而不是一个双精度的“=”检查$discounttype条件。我猜在同一块代码上敲上3个小时会让你哑口无言,错过最明显的错误

首先,我在Drupal 6上

我已使用以下标记创建了一个表单:

$form["cart_".$index] = array(
'#type' => 'image_button',
'#src'=> 'files/imghome/sidebar-add-demo.gif',
'#attributes' => array('rel' => '#item', 'class' => 'buybutton', 'title' => $discounttype),
'#prefix'=>'<p class="renewprop">'.$newren.' for '.$node_abb->field_tipo_abb_value.':</p><p class="renewblock"><span class="pricetag">'.$node_abb->field_prezzo_value.''.$discounttype.'</span>',
'#suffix' =>'</p>' ,
'#submit' =>array('usercp_form_submit'),
);
和其他所有可能的组合,但可能我只是做错了。
实际上,我在网上搜索asnwer已经花了一个小时了,但我找到了任何东西。

我相信你必须使用
$form\u state
而不是
$form\u value
。尝试一下:

$foo = $form_state['clicked_button']['#attributes']['title'];

我建议在为Drupal开发时使用。在开发过程中,它是一个非常有用的工具,允许您在页面加载时查看所有查询的运行情况,停止重定向到调试,以及更多内容。首先,您应该提到表单元素ID。 因此,您可以通过
$form_state[“cart”.$index]['.#attributes'.['title']访问提交按钮

但实际上,为什么不使用隐藏字段(“#type'=>“hidden”)?

感谢您的输入,我实际上是在使用Devel调试东西,查看数组值等等,这就是我可以看到“title”属性设置正确的地方。似乎我仍然无法从您建议的字符串中访问该值。我还是不知道如何访问那个该死的阵列。还是谢谢你的建议。
$foo = $form_state['clicked_button']['#attributes']['title'];