Re: More D7 form woes
Jeff Greenberg <[email protected]> Tue, 17 Feb 2015 17:04:20 -0500
| Newsgroups | gmane.comp.php.drupal.support |
|---|---|
| Message-ID | <[email protected]> |
--===============2322175097440549457== Content-Type: multipart/alternative; boundary=Apple-Mail-B0124E2B-E840-4503-9CFB-17BCFA0100EF Content-Transfer-Encoding: 7bit --Apple-Mail-B0124E2B-E840-4503-9CFB-17BCFA0100EF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable I don't think he filter will do it. I'm thinking my description of how I'm c= hanging the body was too generic. The body is fed through some logic that se= lects strings from it that are likely tag values for the given category, and= then those become links within the body, as well as the checkboxes from the= previous issue.=20 Seems that requesting rebuild at the end of validation causes the usual way o= f changing form values during validation to fail. > On Feb 17, 2015, at 16:31, Jamie Holly <[email protected]> wrote:= >=20 > Instead of doing that, why not just create a custom format filter and do t= he changes then? That also gives the benefit of being resuable on any other p= lace you might need it in the future, like blocks, plus can easily be modifi= ed, undone, whatever by changing the code, since the final markup is cached a= nd the original kept in tact.=20 > Jamie Holly > http://hollyit.net > On 2/17/2015 4:06 PM, Jeff Greenberg wrote: >> So, my last messages were about needing to create and populate checkboxes= based on values determined during the form validation process. This ended u= p working by: >> 1. Creating the fields in hook_form_alter >> 2. Storing the option values as an array during validation in $form_state= ['storage'] >> 3. Checking in hook_form_alter for $form_state[storage], and if present, s= etting the field's options to the stored array >>=20 >> I also need to massage the body value during validation, basically to con= vert some strings to links. I tried the same method as above, which didn't w= ork, with the problem being that $form[body][LANGUAGE_NONE][0] contains a l= arge meta array, so I wasn't sure what to do with the value. >>=20 >> I tried setting the value in form_state[values] during validation, but at= the end of validation at this point in the flow I set rebuild=3Dt= rue, which ends up using the values that were present when the form was subm= itted (thus overwriting my change) ... which is why I ended up doing the oth= er fields in hook_form_alter instead. >>=20 >> I then tried using form_set_value in validate. Two issues there. One is t= hat passing $form[body] as the element doesn't work, I think, because I end u= p with $form_state[values][body] having a value instead of it being in form_= state[values][body][LANGUAGE_NONE][0], and, I think, because of rebuild=3Dtr= ue being set, which causes the change by form_set_value to be overwritten wi= th the value that was there when submit was clicked. >>=20 >> --=20 >> --- >> drupal.org/user/367108 >> linkedin.com/in/jeffrgreenberg >> accidentalcoder.com / ayendesigns.com >> @accidentalcoder >=20 > --=20 > [ Drupal support list | http://lists.drupal.org/ ] --Apple-Mail-B0124E2B-E840-4503-9CFB-17BCFA0100EF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit <html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I don't think he filter will do it. I'm thinking my description of how I'm changing the body was too generic. The body is fed through some logic that selects strings from it that are likely tag values for the given category, and then those become links within the body, as well as the checkboxes from the previous issue. </div><div><br></div><div>Seems that requesting rebuild at the end of validation causes the usual way of changing form values during validation to fail.</div><div><br><br></div><div><br>On Feb 17, 2015, at 16:31, Jamie Holly <<a href="mailto:[email protected]">[email protected]</a>> wrote:<br><br></div><blockquote type="cite"><div> <meta content="text/html; charset=windows-1252" http-equiv="Content-Type"> <div class="moz-cite-prefix">Instead of doing that, why not just create a custom format filter and do the changes then? That also gives the benefit of being resuable on any other place you might need it in the future, like blocks, plus can easily be modified, undone, whatever by changing the code, since the final markup is cached and the original kept in tact. <br> <pre class="moz-signature" cols="72">Jamie Holly <a class="moz-txt-link-freetext" href="http://hollyit.net">http://hollyit.net</a></pre> On 2/17/2015 4:06 PM, Jeff Greenberg wrote:<br> </div> <blockquote cite="mid:CAPpCgRba7My7ML7VWHQricWHisxF3GEN4NS5M-7QaObuPLtMmw@mail.gmail.com" type="cite"> <div dir="ltr">So, my last messages were about needing to create and populate checkboxes based on values determined during the form validation process. This ended up working by: <div>1. Creating the fields in hook_form_alter</div> <div>2. Storing the option values as an array during validation in $form_state['storage']</div> <div>3. Checking in hook_form_alter for $form_state[storage], and if present, setting the field's options to the stored array</div> <div><br> </div> <div>I also need to massage the body value during validation, basically to convert some strings to links. I tried the same method as above, which didn't work, with the problem being that $form[body][LANGUAGE_NONE][0] contains a large meta array, so I wasn't sure what to do with the value.</div> <div><br> </div> <div>I tried setting the value in form_state[values] during validation, but at the end of validation at this point in the flow I set rebuild=true, which ends up using the values that were present when the form was submitted (thus overwriting my change) ... which is why I ended up doing the other fields in hook_form_alter instead.</div> <div><br> </div> <div>I then tried using form_set_value in validate. Two issues there. One is that passing $form[body] as the element doesn't work, I think, because I end up with $form_state[values][body] having a value instead of it being in form_state[values][body][LANGUAGE_NONE][0], and, I think, because of rebuild=true being set, which causes the change by form_set_value to be overwritten with the value that was there when submit was clicked.<br clear="all"> <div><br> </div> -- <br> <div class="gmail_signature">--- <div><a moz-do-not-send="true" href="http://drupal.org/user/367108" target="_blank">drupal.org/user/367108</a></div> <div><a moz-do-not-send="true" href="http://linkedin.com/in/jeffrgreenberg" target="_blank">linkedin.com/in/jeffrgreenberg</a></div> <div><a moz-do-not-send="true" href="http://accidentalcoder.com" target="_blank">accidentalcoder.com</a> / <a moz-do-not-send="true" href="http://ayendesigns.com" target="_blank">ayendesigns.com</a></div> <div>@accidentalcoder</div> </div> </div> </div> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <br> </blockquote> <br> </div></blockquote><blockquote type="cite"><div><span>-- </span><br><span>[ Drupal support list | <a href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]</span></div></blockquote></body></html> --Apple-Mail-B0124E2B-E840-4503-9CFB-17BCFA0100EF-- --===============2322175097440549457== 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/ ] --===============2322175097440549457==--