Re: Changing checkboxes options during hook_node_validate
Jeff Greenberg <[email protected]> Wed, 11 Feb 2015 10:43:27 -0500
| Newsgroups | gmane.comp.php.drupal.support |
|---|---|
| Message-ID | <CAPpCgRbWrvQq=myoAHMUAM1MaJFCtUGG=0Y5rOMSyH9eVDBTQQ@mail.gmail.com> |
--===============1354777860492150934== Content-Type: multipart/alternative; boundary=001a113f8e344c9a81050ed1dd30 --001a113f8e344c9a81050ed1dd30 Content-Type: text/plain; charset=UTF-8 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. On Wed, Feb 11, 2015 at 9:31 AM, Jeff Greenberg < [email protected]> wrote: > I have a node form that contains a checkboxes field with options NULL at > the time the form is displayed. > > 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. > > 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. > > 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. > > > -- > --- > drupal.org/user/367108 > linkedin.com/in/jeffrgreenberg > accidentalcoder.com / ayendesigns.com > @accidentalcoder > -- --- drupal.org/user/367108 linkedin.com/in/jeffrgreenberg accidentalcoder.com / ayendesigns.com @accidentalcoder --001a113f8e344c9a81050ed1dd30 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">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_for= m_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_st= ate gets the information for the field when rebuilding the form.</div><div = class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Feb 11, 2015 a= t 9:31 AM, Jeff Greenberg <span dir=3D"ltr"><<a href=3D"mailto:listmail.= [email protected]" target=3D"_blank">[email protected]</a>= ></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0= 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div = style=3D"margin:0px 5px 5px 0px;padding:0px;border:0px;font-size:14px;verti= cal-align:baseline;width:660px;word-wrap:break-word;line-height:1.3;color:r= gb(68,68,68);font-family:'Lucida Grande','DejaVu Sans','= ;Bitstream Vera Sans',Verdana,Arial,sans-serif"><p style=3D"margin:0px = 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">I have a= node form that contains a checkboxes field with options NULL at the time t= he form is displayed.</p><p style=3D"margin:0px 0px 1em;padding:0px;border:= 0px;vertical-align:baseline;clear:both">During node_validate, if certain cr= iteria is met, an array of options (checkboxes) is created, and the form ne= eds to be redisplayed with the checkboxes as part of it.</p><p style=3D"mar= gin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">= I've tried setting #options =3D the new array in the $form, in $form_st= ate[original_form], etc all to no avail. The field doesn't change.</p><= p style=3D"margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baselin= e;clear:both">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 foun= d it to the new options array, and again, no change. I am setting $form_sta= te[rebuild] to true, and even tried explicitly calling for the form to be r= ebuilt.</p><span class=3D"HOEnZb"><font color=3D"#888888"><div><br></div></= font></span></div><span class=3D"HOEnZb"><font color=3D"#888888"><div><br><= /div>-- <br><div>---<div><a href=3D"http://drupal.org/user/367108" target= =3D"_blank">drupal.org/user/367108</a></div><div><a href=3D"http://linkedin= .com/in/jeffrgreenberg" target=3D"_blank">linkedin.com/in/jeffrgreenberg</a= ></div><div><a href=3D"http://accidentalcoder.com" target=3D"_blank">accide= ntalcoder.com</a> / <a href=3D"http://ayendesigns.com" target=3D"_blank">ay= endesigns.com</a></div><div>@accidentalcoder</div></div> </font></span></div> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class= =3D"gmail_signature">---<div><a href=3D"http://drupal.org/user/367108" targ= et=3D"_blank">drupal.org/user/367108</a></div><div><a href=3D"http://linked= in.com/in/jeffrgreenberg" target=3D"_blank">linkedin.com/in/jeffrgreenberg<= /a></div><div><a href=3D"http://accidentalcoder.com" target=3D"_blank">acci= dentalcoder.com</a> / <a href=3D"http://ayendesigns.com" target=3D"_blank">= ayendesigns.com</a></div><div>@accidentalcoder</div></div> </div> --001a113f8e344c9a81050ed1dd30-- --===============1354777860492150934== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- [ Drupal support list | http://lists.drupal.org/ ] --===============1354777860492150934==--