<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Also make sure your hook_form_alter has & signs in front of the $form parameter (as well as $form_state) to indicate pass by reference. It’s easy to overlook
that if your field isn’t changing when you think you should. If you forget to do this hook_form_alter won’t actually alter anything, but it won’t give you any errors either. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">mymodule_hook_form_FORMID_alter(&$form, &$form_state);
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> support-bounces@drupal.org [mailto:support-bounces@drupal.org]
<b>On Behalf Of </b>Jeff Greenberg<br>
<b>Sent:</b> Wednesday, February 11, 2015 7:43 AM<br>
<b>To:</b> support@drupal.org<br>
<b>Subject:</b> Re: [support] Changing checkboxes options during hook_node_validate<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">One thing that is either part of the issue, or a separate issue that impacts this, is that the checkboxes field is added via hook_form_alter. I notice that although the field appears in $form_state[values] it does not appear in $form_state[field],
so I'm wondering where $form_state gets the information for the field when rebuilding the form.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Feb 11, 2015 at 9:31 AM, Jeff Greenberg <<a href="mailto:listmail.ayendesigns@gmail.com" target="_blank">listmail.ayendesigns@gmail.com</a>> wrote:<o:p></o:p></p>
<div>
<div style="margin-right:3.75pt;margin-bottom:3.75pt;word-wrap:break-word">
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Verdana","sans-serif";color:#444444">I have a node form that contains a checkboxes field with options NULL at the time the form is displayed.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Verdana","sans-serif";color:#444444">During node_validate, if certain criteria is met, an array of options (checkboxes) is created, and the form needs to be redisplayed with the checkboxes as part of it.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Verdana","sans-serif";color:#444444">I've tried setting #options = the new array in the $form, in $form_state[original_form], etc all to no avail. The field doesn't change.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Verdana","sans-serif";color:#444444">I also set one checkbox in the field at the start, so that I could find it in the $form and $form_state structures, changed where I found it to the new options array, and again,
no change. I am setting $form_state[rebuild] to true, and even tried explicitly calling for the form to be rebuilt.<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.5pt;font-family:"Verdana","sans-serif";color:#888888"><o:p> </o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span class="hoenzb"><span style="color:#888888">-- </span><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:#888888">---</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="color:#888888"><a href="http://drupal.org/user/367108" target="_blank">drupal.org/user/367108</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><a href="http://linkedin.com/in/jeffrgreenberg" target="_blank">linkedin.com/in/jeffrgreenberg</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><a href="http://accidentalcoder.com" target="_blank">accidentalcoder.com</a> /
<a href="http://ayendesigns.com" target="_blank">ayendesigns.com</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888">@accidentalcoder<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal">---<o:p></o:p></p>
<div>
<p class="MsoNormal"><a href="http://drupal.org/user/367108" target="_blank">drupal.org/user/367108</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://linkedin.com/in/jeffrgreenberg" target="_blank">linkedin.com/in/jeffrgreenberg</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://accidentalcoder.com" target="_blank">accidentalcoder.com</a> /
<a href="http://ayendesigns.com" target="_blank">ayendesigns.com</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">@accidentalcoder<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>