制作单选按钮
很抱歉这个问题,但是是否可以从这段代码中制作单选按钮而不是选择列表?
function _nodereview_form_review(&$form, $axis, $node) {
static $options;
if (!isset($options)) {
$options = array(
20 => -2,
40 => -1,
60 => 0,
80 => 1,
100 => 2,
);
}
$form['reviews'][$axis->aid] = array(
'#type' => 'fieldset',
'#title' => $axis->tag,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['reviews'][$axis->aid]['score'] = array(
'#type' => 'select',
'#title' => t('Score'),
'#options' => $options,
'#default_value' => $node->reviews[$axis->aid]['score'] ? $node->reviews[$axis->aid]['score'] : 50,
'#description' => $axis->description,
'#required' => TRUE,
);
if (NODEREVIEW_FIVESTAR_ENABLE) {
$form['reviews'][$axis->aid]['score']['#type'] = 'fivestar';
$form['reviews'][$axis->aid]['score']['#stars'] = variable_get('nodereview_fivestar_stars', 5);
}
$form['reviews'][$axis->aid]['review'] = array(
'#type' => 'textarea',
'#title' => t('Review'),
'#default_value' => $node->reviews[$axis->aid]['review'],
'#required' => TRUE,
);
}
我知道 '#type' => 'select' 应该是 '#type' => “广播”,但其他东西也应该改变。 我不知道到底是什么。
任何建议都非常感激地接受。
Sorry for this question, but is it possible to make radio buttons instead of select list from this piece of code?
function _nodereview_form_review(&$form, $axis, $node) {
static $options;
if (!isset($options)) {
$options = array(
20 => -2,
40 => -1,
60 => 0,
80 => 1,
100 => 2,
);
}
$form['reviews'][$axis->aid] = array(
'#type' => 'fieldset',
'#title' => $axis->tag,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['reviews'][$axis->aid]['score'] = array(
'#type' => 'select',
'#title' => t('Score'),
'#options' => $options,
'#default_value' => $node->reviews[$axis->aid]['score'] ? $node->reviews[$axis->aid]['score'] : 50,
'#description' => $axis->description,
'#required' => TRUE,
);
if (NODEREVIEW_FIVESTAR_ENABLE) {
$form['reviews'][$axis->aid]['score']['#type'] = 'fivestar';
$form['reviews'][$axis->aid]['score']['#stars'] = variable_get('nodereview_fivestar_stars', 5);
}
$form['reviews'][$axis->aid]['review'] = array(
'#type' => 'textarea',
'#title' => t('Review'),
'#default_value' => $node->reviews[$axis->aid]['review'],
'#required' => TRUE,
);
}
I know that '#type' => 'select' should be '#type' => 'radio', but something else also should be changed. I don't know what exactly.
Any suggestions are gratefully accepted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,#options 需要转换为每个单选按钮的值。 您可能还需要为每个按钮添加标签。
Well, for starters, the #options will need to be converted to the value for each radio button. You'll also probably need to add labels for each button as well.