<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">Hi,<br>
    </p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">In Drupal 7 I'm working on a module that deals with node
      forms. <br>
      I must set some values from code. Actually what I do is save some
      user input<br>
      and populate the node form with the values. <br>
    </p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">I can easily modify field values from<span
        class="Apple-converted-space"> </span><strong style="margin:
        0px; padding: 0px; border: 0px; font-size: 14px; vertical-align:
        baseline; font-weight: bold; ">hook_form_alter</strong><span
        class="Apple-converted-space"> </span>except
      term_reference_tree.<br>
      It looks like that when hook_form_alter gets called, the
      term_reference_tree field<br>
      <span class="Apple-converted-space"></span><em style="margin: 0px;
        padding: 0px; border: 0px; font-size: 14px; vertical-align:
        baseline; font-style: italic; ">only has some meta data</em><span
        class="Apple-converted-space"> </span>and doesn't contain the
      checkboxes for the tree.<br>
    </p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">They are missing in<span class="Apple-converted-space"> </span><strong
        style="margin: 0px; padding: 0px; border: 0px; font-size: 14px;
        vertical-align: baseline; font-weight: bold; ">hook_field_attach_form</strong><span
        class="Apple-converted-space"> </span>too. However, when I check
      the field<br>
      upon form submit, the checkboxes are there.</p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">On form submit the field has a key<span
        class="Apple-converted-space"> </span><strong style="margin:
        0px; padding: 0px; border: 0px; font-size: 14px; vertical-align:
        baseline; font-weight: bold; ">[#options]</strong><span
        class="Apple-converted-space"> </span>and an array with the
      checkbox tree,<br>
      but these keys are missing in hook_form_alter. There's a function<br>
      <span class="Apple-converted-space"></span><strong style="margin:
        0px; padding: 0px; border: 0px; font-size: 14px; vertical-align:
        baseline; font-weight: bold; ">term_reference_tree_process_checkbox_tree</strong><span
        class="Apple-converted-space"> </span>which I tried to call from
      my module.<br>
      It builds the frame of the checkbox tree, but not the actual
      checkboxes. Output is like this:<br>
    </p>
    <pre class="default prettyprint" style="margin: 0px 0px 10px; padding: 5px; border: 0px; font-size: 12px; vertical-align: baseline; overflow: auto; width: auto; max-height: 600px; font-family: 'Droid Sans Mono', Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-color: rgb(243, 243, 243); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; display: block; color: rgb(57, 51, 24); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial; "><code style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; font-f
 amily: 
'Droid Sans Mono', Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: rgb(34, 34, 34); background-image: none; background-position: initial initial; background-repeat: initial initial; "><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#options_tree] =&gt; Array</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">

</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#options] =&gt; Array</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">

</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="lit" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(149, 56, 56); ">0</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">]</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; "> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">=&gt;</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; "> </span><span class="typ" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(43, 145, 175); ">Array</
 span><s
pan class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#type] =&gt; checkbox_tree_level</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#max_choices] =&gt; 1</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#leaves_only] =&gt; </span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#start_minimized] =&gt; </span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#depth] =&gt; 1</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
        </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">[</span><span class="com" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(134, 134, 134); ">#level_start_minimized] =&gt; </span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
    </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: rgb(20, 86, 128); ">)</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 12px; vertical-align: baseline; color: black; ">
</span></code></pre>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">As you can see, the <b>#options</b> array is empty, and
      the checkbox array only has some default<br>
      values.<br>
      I tried to simply insert values in the array (and set the keys
      where they should belong), set<br>
      <span class="Apple-converted-space"></span><strong style="margin:
        0px; padding: 0px; border: 0px; font-size: 14px; vertical-align:
        baseline; font-weight: bold; ">#checked</strong><span
        class="Apple-converted-space"> </span>to true like with regular
      checkboxes, but when the form is presented to the user,<br>
      these values got overwritten with empty values.</p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">I also tried to modify weight, to put my module before
      term_reference_tree, but it didn't help.</p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">Is there a way to check some checkboxes from code<span
        class="Apple-converted-space"> </span><b><em style="margin: 0px;
          padding: 0px; border: 0px; font-size: 14px; vertical-align:
          baseline; font-style: italic; ">before</em></b><span
        class="Apple-converted-space"> </span>it the form gets displayed<br>
      to the user? I am not too familiar with term reference tree
      module, but I think there must<br>
      be some function I can call or another hook I can catch to build
      the checkbox tree so I<br>
      can populate it.<br>
    </p>
    <p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size:
      14px; vertical-align: baseline; clear: both; word-wrap:
      break-word; color: rgb(68, 68, 68); font-family: 'Lucida Grande',
      'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18px; orphans: 2; text-align:
      left; text-indent: 0px; text-transform: none; white-space: normal;
      widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); ">Thanks in advance,<br>
      Balazs<br>
    </p>
  </body>
</html>