我没有经验的PHP。我遵循几个教程,使用template.php中的主题方法修改我的Drupal表单。修改Drupal表单字段 - [#weight]不被尊重的数组?
由于某些原因,字段的[#weight]属性不符合其值。我想将Subject字段[subject]上的Category字段[cid]移动。这些是代码行我用:
$form['cid']['#weight'] = 0.003;
$form['subject']['#weight'] = 0.004;
当我打印我的阵列来查看我看到的值发生了变化,但是当我渲染表单没有更改。每次修改后,我已经清除了性能缓存。
如果你有兴趣,这里是我的印刷阵列的一个片段:
[subject] => Array
(
[#type] => textfield
[#title] => Subject
[#maxlength] => 255
[#required] => 1
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => subject
)
[#array_parents] => Array
(
[0] => subject
)
[#weight] => 0.004
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#input] => 1
[#size] => 60
[#autocomplete_path] =>
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => subject
[#id] => edit-subject
[#value] =>
[#defaults_loaded] => 1
[#sorted] => 1
)
[cid] => Array
(
[#type] => select
[#title] => Category
[#default_value] => 1
[#options] => Array
(
[1] => General Enquiries
[2] => Support
)
[#required] => 1
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => cid
)
[#array_parents] => Array
(
[0] => cid
)
[#weight] => 0.003
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#input] => 1
[#size] => 0
[#multiple] =>
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => cid
[#id] => edit-cid
[#value] => 1
[#defaults_loaded] => 1
[#sorted] => 1
)
大加赞赏,
克里斯
这是有道理的。那么有没有办法解决这个问题?我只需要一个例外就是联系表单。我知道我可以主题它,但有没有编码修复? – 2010-07-31 10:13:43
@克里斯,是的,没有。我已经用更多信息和一些可能的解决方案更新了我的答案。 – 2010-07-31 10:38:15
感谢您的解决方案。我了解CCK现在如何处理表单字段。我想如果我有一个自定义窗体,那么我会走这条路线,但因为我只需要重新排列整个站点范围内的一个[cid]字段,我只需要使用CSS就可以了。我会记下您的解决方案以备将来参考。非常感谢! – 2010-07-31 10:46:37