提交按钮
任何人都可以帮助我理解它为什么不起作用吗?
$form['user_fields']['optinal_packages'] = array(
'#type' => 'select',
'#title' => t('Optional Packages'),
'#options' => $packages_array,
//'#weight' => 15,
'#description' => t('Please press the "Push" button to update device package.'),
'#default_value' => -1,
);
$form['user_fields']['push'] = array(
'#type' => 'submit',
'#value' => t('Push'),
// '#weight' => 16,
'#prefix' => '<div id="phone_user_push_package">',
'#suffix' => '</div>',
'#states' => array(
'visible' => array( // Action to take: Make visible.
//':input[name="optinal_packages"]' => array('!value' => '-1'),
'select[name="optinal_packages"]' => array('!value' => '-1'),
),
),
);
由于 布施
答案 0 :(得分:0)
将代码更改为
$form['user_fields']['push'] = array(
'#type' => 'submit',
'#value' => t('Push'),
// '#weight' => 16,
'#prefix' => '<div id="phone_user_push_package">',
'#suffix' => '</div>',
'#states' => array(
'invisible' => array( // edited line
':select[name="optinal_packages"]' => array('value' => '-1'), // edited line
),
),
);
将select[name="optinal_packages"]
更改为:select[name="optinal_packages"]
。如果它不起作用,请尝试将选择器更改为类似CSS的#edit-optinal-packages
。
因此代码将是:
'#edit-optinal-packages' => array('value' => '-1'),