Re: More D7 form woes
Jeff Greenberg <[email protected]> Thu, 19 Feb 2015 08:23:45 -0500
| Newsgroups | gmane.comp.php.drupal.support |
|---|---|
| Message-ID | <[email protected]> |
--===============7868441533438540613== Content-Type: multipart/alternative; boundary=Apple-Mail-7ADE843A-59BA-467B-B92A-7DDA597B9168 Content-Transfer-Encoding: 7bit --Apple-Mail-7ADE843A-59BA-467B-B92A-7DDA597B9168 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Dave, beautiful! Thanks for the secret sauce. I kept telling myself, "it's o= nly a html form..." > On Feb 18, 2015, at 11:13, Metzler, David <[email protected]> wrote: >=20 > Sounds like you got it, but it looks like you were struggling with changin= g values on validation, which I=E2=80=99ve struggled with before so I though= t I=E2=80=99d let you know the secret sauce. It=E2=80=99s the $form_state[=E2= =80=98input=E2=80=99] that people usually miss. > =20 > When changing the values in a validation handler or form rebuilding functi= on do the following: > 1.) Change the #default value in the form: > 2.) Change the corresponding $form_state[=E2=80=98values=E2=80=99] elem= ent > 3.) Change the $form_state[=E2=80=98input=E2=80=99] element for the sam= e value. > =20 > I usually do this in one statement like: > =20 > $form[=E2=80=98myfield=E2=80=99][=E2=80=98#default_value=E2=80=99] =3D $fo= rm_state[=E2=80=98values=E2=80=99][=E2=80=98myfield=E2=80=99] =3D $form_stat= e[=E2=80=98input=E2=80=99][=E2=80=98my_field=E2=80=99] =3D $foo; > =20 > Dave >=20 --Apple-Mail-7ADE843A-59BA-467B-B92A-7DDA597B9168 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Dave, beautiful! Thanks for the secret= sauce. I kept telling myself, "it's only a html form..."<br><br><br></div><= div><br>On Feb 18, 2015, at 11:13, Metzler, David <<a href=3D"mailto:metz= [email protected]">[email protected]</a>> wrote:<br><br></div><bloc= kquote type=3D"cite"> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8"> <meta name=3D"Generator" content=3D"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:Consolas; panose-1:2 11 6 9 2 2 4 3 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;} pre {mso-style-priority:99; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New";} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-priority:99; mso-style-link:"HTML Preformatted"; font-family:"Consolas","serif";} span.hoenzb {mso-style-name:hoenzb;} span.EmailStyle20 {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;} /* List Definitions */ @list l0 {mso-list-id:1193374747; mso-list-type:hybrid; mso-list-template-ids:-1051061000 1381377926 67698713 67698715 6769= 8703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-text:"%1\.\)"; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level2 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level3 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} @list l0:level4 {mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level5 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level6 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} @list l0:level7 {mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level8 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l0:level9 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} @list l1 {mso-list-id:1671905919; mso-list-type:hybrid; mso-list-template-ids:1937643412 67698703 67698713 67698715 6769870= 3 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level2 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level3 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} @list l1:level4 {mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level5 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level6 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} @list l1:level7 {mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level8 {mso-level-number-format:alpha-lower; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-.25in;} @list l1:level9 {mso-level-number-format:roman-lower; mso-level-tab-stop:none; mso-level-number-position:right; text-indent:-9.0pt;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> <div class=3D"WordSection1"> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D">Sounds like you got it, but= it looks like you were struggling with changing values on validation, which= I=E2=80=99ve struggled with before so I thought I=E2=80=99d let you know the secret sauce. It=E2=80=99s the $form_state[=E2=80=98input=E2= =80=99] that people usually miss. <o:p> </o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D">When changing the values in= a validation handler or form rebuilding function do the following:<o:p></o:= p></span></p> <p class=3D"MsoListParagraph" style=3D"text-indent:-.25in;mso-list:l0 level1= lfo2"><!--[if !supportLists]--><span style=3D"font-size:11.0pt;font-family:= "Calibri","sans-serif";color:#1F497D"><span style=3D"mso= -list:Ignore">1.)<span style=3D"font:7.0pt "Times New Roman"">&nbs= p; </span></span></span><!--[endif]--><span style=3D"font-size:11.0pt;font-fami= ly:"Calibri","sans-serif";color:#1F497D">Change the #def= ault value in the form: <o:p></o:p></span></p> <p class=3D"MsoListParagraph" style=3D"text-indent:-.25in;mso-list:l0 level1= lfo2"><!--[if !supportLists]--><span style=3D"font-size:11.0pt;font-family:= "Calibri","sans-serif";color:#1F497D"><span style=3D"mso= -list:Ignore">2.)<span style=3D"font:7.0pt "Times New Roman"">&nbs= p; </span></span></span><!--[endif]--><span style=3D"font-size:11.0pt;font-fami= ly:"Calibri","sans-serif";color:#1F497D">Change the corr= esponding $form_state[=E2=80=98values=E2=80=99] element <o:p></o:p></span></p> <p class=3D"MsoListParagraph" style=3D"text-indent:-.25in;mso-list:l0 level1= lfo2"><!--[if !supportLists]--><span style=3D"font-size:11.0pt;font-family:= "Calibri","sans-serif";color:#1F497D"><span style=3D"mso= -list:Ignore">3.)<span style=3D"font:7.0pt "Times New Roman"">&nbs= p; </span></span></span><!--[endif]--><span style=3D"font-size:11.0pt;font-fami= ly:"Calibri","sans-serif";color:#1F497D">Change the $for= m_state[=E2=80=98input=E2=80=99] element for the same value. <o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D">I usually do this in one st= atement like: <o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D">$form[=E2=80=98myfield=E2=80= =99][=E2=80=98#default_value=E2=80=99] =3D $form_state[=E2=80=98values=E2=80= =99][=E2=80=98myfield=E2=80=99] =3D $form_state[=E2=80=98input=E2=80=99][=E2= =80=98my_field=E2=80=99] =3D $foo; <o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal= ibri","sans-serif";color:#1F497D">Dave<o:p></o:p></span></p> <p class=3D"MsoNormal"><br></p></div></blockquote></body></html>= --Apple-Mail-7ADE843A-59BA-467B-B92A-7DDA597B9168-- --===============7868441533438540613== 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/ ] --===============7868441533438540613==--