我有两个表单字段,其中一个取决于另一个,即如果优惠券值为“是”,则显示优惠券代码文本框
$form['coupon'] = array(
'#id' => 'coupon',
'#key_type' => 'associative',
'#multiple_toggle' => '1',
'#type' => 'select',
'#options' => array(
'' => 'Select',
'Yes' => 'Yes',
'No' => 'No'
),
'#default_value' => '',
'#required' => TRUE
);
$form['coupon_code'] = array(
'#id' => 'coupon_code',
'#type' => 'textfield',
'#default_value' => $couponCode,
'#required' => TRUE,
'#states' => array(
'visible' => array(// action to take.
':input[name="coupon"]' => array('value' => 'Yes'),
),
),
);
在我的 tpl 文件中
<tr>
<td class='formlabel' valign=middle>Coupon</td>
<td align=left>
<?php echo render($form['coupon']); ?>
<font class='redmark'>*</font>
</td>
</tr>
<tr>
<td class='formlabel' valign=middle>Coupon Code</td>
<td align=left>
<?php echo render($form['coupon_code']); ?>
<font class='redmark'>*</font>
</td>
</tr>
当优惠券值为“否”时,优惠券代码不可见,但我也想隐藏标签“优惠券代码”,我该怎么做?