Re: More D7 form woes

Jamie Holly <[email protected]> Tue, 17 Feb 2015 16:31:36 -0500
Newsgroups gmane.comp.php.drupal.support
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============0802772690769285937==
Content-Type: multipart/alternative;
	boundary="------------050105020003090203040706"

This is a multi-part message in MIME format.
--------------050105020003090203040706
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

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.

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 up 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, setting the field's options to the stored array
>
> 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.
>
> 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.
>
> 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.
>
> -- 
> ---
> drupal.org/user/367108 <http://drupal.org/user/367108>
> linkedin.com/in/jeffrgreenberg <http://linkedin.com/in/jeffrgreenberg>
> accidentalcoder.com <http://accidentalcoder.com> / ayendesigns.com 
> <http://ayendesigns.com>
> @accidentalcoder
>
>


--------------050105020003090203040706
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dwindows-1252"
      http-equiv=3D"Content-Type">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"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=3D"moz-signature" cols=3D"72">Jamie Holly
<a class=3D"moz-txt-link-freetext" href=3D"http://hollyit.net">http://hol=
lyit.net</a></pre>
      On 2/17/2015 4:06 PM, Jeff Greenberg wrote:<br>
    </div>
    <blockquote
cite=3D"mid:[email protected]=
l.com"
      type=3D"cite">
      <div dir=3D"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 =A0$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=3Dtrue, 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=3Dtrue 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=3D"all">
          <div><br>
          </div>
          -- <br>
          <div class=3D"gmail_signature">---
            <div><a moz-do-not-send=3D"true"
                href=3D"http://drupal.org/user/367108" target=3D"_blank">=
drupal.org/user/367108</a></div>
            <div><a moz-do-not-send=3D"true"
                href=3D"http://linkedin.com/in/jeffrgreenberg"
                target=3D"_blank">linkedin.com/in/jeffrgreenberg</a></div=
>
            <div><a moz-do-not-send=3D"true"
                href=3D"http://accidentalcoder.com" target=3D"_blank">acc=
identalcoder.com</a>
              / <a moz-do-not-send=3D"true" href=3D"http://ayendesigns.co=
m"
                target=3D"_blank">ayendesigns.com</a></div>
            <div>@accidentalcoder</div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class=3D"mimeAttachmentHeader"></fieldset>
      <br>
    </blockquote>
    <br>
  </body>
</html>

--------------050105020003090203040706--

--===============0802772690769285937==
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/ ]
--===============0802772690769285937==--