Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying Drupal Form Fields - [#weight] in array not being respected?
    primarykey
    data
    text
    <p>I don't have experience in php. I've followed a few tutorials to modify my Drupal forms using the theme method in template.php.</p> <p>For some reason the [#weight] property for a field does not adhere to its values. I'd like to move the Category field [cid] above Subject field [subject]. These are the lines of code I used:</p> <pre><code>$form['cid']['#weight'] = 0.003; $form['subject']['#weight'] = 0.004; </code></pre> <p>When I print my array to view I see the values have changed, but when I render the form no changes are made. I have already cleared performance cache after every modification.</p> <p>If you're interested here is a snippet of my printed array:</p> <pre><code>[subject] =&gt; Array ( [#type] =&gt; textfield [#title] =&gt; Subject [#maxlength] =&gt; 255 [#required] =&gt; 1 [#post] =&gt; Array ( ) [#programmed] =&gt; [#tree] =&gt; [#parents] =&gt; Array ( [0] =&gt; subject ) [#array_parents] =&gt; Array ( [0] =&gt; subject ) [#weight] =&gt; 0.004 [#processed] =&gt; 1 [#description] =&gt; [#attributes] =&gt; Array ( ) [#input] =&gt; 1 [#size] =&gt; 60 [#autocomplete_path] =&gt; [#process] =&gt; Array ( [0] =&gt; form_expand_ahah ) [#name] =&gt; subject [#id] =&gt; edit-subject [#value] =&gt; [#defaults_loaded] =&gt; 1 [#sorted] =&gt; 1 ) [cid] =&gt; Array ( [#type] =&gt; select [#title] =&gt; Category [#default_value] =&gt; 1 [#options] =&gt; Array ( [1] =&gt; General Enquiries [2] =&gt; Support ) [#required] =&gt; 1 [#post] =&gt; Array ( ) [#programmed] =&gt; [#tree] =&gt; [#parents] =&gt; Array ( [0] =&gt; cid ) [#array_parents] =&gt; Array ( [0] =&gt; cid ) [#weight] =&gt; 0.003 [#processed] =&gt; 1 [#description] =&gt; [#attributes] =&gt; Array ( ) [#input] =&gt; 1 [#size] =&gt; 0 [#multiple] =&gt; [#process] =&gt; Array ( [0] =&gt; form_expand_ahah ) [#name] =&gt; cid [#id] =&gt; edit-cid [#value] =&gt; 1 [#defaults_loaded] =&gt; 1 [#sorted] =&gt; 1 ) </code></pre> <p>Much appreciated,</p> <p>Chris</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload