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.
mymodule_hook_form_FORMID_alter(&$form, &$form_state);
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Jeff Greenberg Sent: Wednesday, February 11, 2015 7:43 AM To: support@drupal.org Subject: Re: [support] Changing checkboxes options during hook_node_validate
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 <listmail.ayendesigns@gmail.commailto:listmail.ayendesigns@gmail.com> 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/367108http://drupal.org/user/367108 linkedin.com/in/jeffrgreenberghttp://linkedin.com/in/jeffrgreenberg accidentalcoder.comhttp://accidentalcoder.com / ayendesigns.comhttp://ayendesigns.com @accidentalcoder
-- --- drupal.org/user/367108http://drupal.org/user/367108 linkedin.com/in/jeffrgreenberghttp://linkedin.com/in/jeffrgreenberg accidentalcoder.comhttp://accidentalcoder.com / ayendesigns.comhttp://ayendesigns.com @accidentalcoder