老葛的Drupal培训班 Think in Drupal
重量元素(不要与属性#weight混淆了)是一个用来声明重量的下拉选择框:
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $edit['weight'],
'#delta' => 10,
'#description' => t('In listings, the heavier vocabularies will sink and the
lighter vocabularies will be positioned nearer the top.'),
);
前面代码的显示结果如图10-15所示。
图10-15 重量元素
属性#delta决定了重量的可供选择范围,默认为10.例如,如果你将#delta设为50,那么重量的范围就应该为从-50到50. 重量元素的常用属性如下:#attributes, #delta (默认为 10), #default_value, #description, #prefix, #required, #suffix, #title, 和#weight。#process属性默认为array('process_weight', 'form_expand_ahah')。