Re: More thoughts on Forge->Formo conversion
Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> Mon, 29 Apr 2013 16:06:06 +0200
| Newsgroups | gmane.comp.web.gallery.devel |
|---|---|
| Message-ID | <CA+z51A7_tSTD0d8ibEXb0YtbSVbCFh5O6w_uuw9-CVWX-ubBTQ@mail.gmail.com> |
--===============5561773556618493511== Content-Type: multipart/alternative; boundary=001a11c329e8f4a5ef04db80633e --001a11c329e8f4a5ef04db80633e Content-Type: text/plain; charset=UTF-8 Hey Chad and Bharat, Thanks for the feedback. Sounds good to me - semantic tags it is. I just finished redoing the templates, and the login controller appears to render exactly like it used to, both in html and ajax modes. Sweet! Take care, Shad On 29 April 2013 00:42, Bharat Mediratta <[email protected]> wrote: > > +1 for using <fieldset> and other semantic tags. We've been down this > road three times before (G1, G2 and G3!) and in all cases keep coming back > to the value of semantic tags... > > > On Sun, Apr 28, 2013 at 3:29 PM, Chad Kieffer <[email protected]> wrote: > >> Hey Shad, >> >> Nice work on combining the login routes. That simplifies things nicely. >> >> I'll always argue for keeping semantically meaningful tags over div tags. >> I don't think using divs simplifies theming all that much. Sure, if a >> themer doesn't want the default border of a fieldset they have to override >> that, but it's just a few lines of CSS. I'd also argue for the use of >> legend tags to label forms or form sections. >> >> Fieldsets group related form elements, even on the simplest of forms. I >> believe we get accessibility points, even if it's not something users are >> clamoring for in Gallery. >> >> My $.02. >> >> - Chad >> >> On Apr 28, 2013, at 4:03 PM, Shad Laws wrote: >> >> Alright, I think I have one complete example finished up - the login >> controller works! I squashed four routes (login/ajax, login/auth_ajax, >> login/html, login/auth_html) into one (login). Also, I made some tweaks to >> Formo so we could keep all of our labels/errors inline (as opposed to in >> external message files) and automatically stick in our CSRF token. >> >> Next step - work on the formatting. It seems that Gallery's old template >> used <li> elements for each input with a <fieldset> for each group. By >> default, Formo's templates use a <div> on everything. Before I rewrite >> them all, I thought I'd ask: is there a reason why we should prefer one or >> the other? Using li/fieldset seems better for backward compatibility, but >> using divs seems more flexible for theming... thoughts? >> >> Take care, >> Shad >> >> >> On 24 April 2013 18:42, Bharat Mediratta <[email protected]> wrote: >> >>> >>> Fantastic. I never liked the way we had this split up before so it's >>> nice to see that Formo can streamline it for us. >>> >>> I've also never been happy with our form/{add,edit}/ routing - that was >>> a framework put in place before it was clear what the true need would be >>> and it's only used in 9 places. I'd be happy to see that routing go away >>> and let each controller do it in a more ad hoc approach. Take a look at >>> that while you're in there and let me know what you think. >>> >>> -Bharat >>> >>> >>> On Wed, Apr 24, 2013 at 1:13 AM, Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> wrote: >>> >>>> Hey everyone, >>>> >>>> I'm working on getting acquainted with Formo a bit more, and it seems >>>> like the default, expected actions of Formo is a bit different than how we >>>> were using Forge in Gallery 3.0.x. >>>> >>>> Before, we usually (but not always) had a separate controller action >>>> for showing a form vs. validating a form (e.g. action_edit() and >>>> action_save()). Also, it was common to have a third function generate the >>>> form for us, so we ended handling the form in three places. >>>> >>>> It seems that the default, expected behavior of Formo is to do this in >>>> one place with one action. It's smart enough to figure out if we have post >>>> data or not, and therefore if we are in "edit" or "save" mode (following >>>> the example). An example: >>>> >>>> public function action_edit() { >>>> $form = Formo::form(...) >>>> ->....; // build form, load with default values. >>>> >>>> if ($form->load()->validate()) { >>>> // load() gets the values from post/files and fills the values, >>>> // then validate() checks stuff and does nothing if the form isn't >>>> // yet sent (nothing loaded) or adds errors if it was. >>>> >>>> // Do some more stuff... then: >>>> Message::success(t("Done!")); >>>> // And/or: >>>> $this->redirect("somewhere/else"); >>>> } >>>> >>>> $view = .....; >>>> $view->form = $form; >>>> >>>> $this->response->body($view); >>>> } >>>> >>>> I can overload a couple Formo classes to ensure that each form contains >>>> and validates our csrf, similar to what we did with Forge. >>>> >>>> Does this seem like a reasonable approach? Is there some other reason >>>> why we intentionally divided these up into multiple actions before? >>>> >>>> Take care, >>>> Shad >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Try New Relic Now & We'll Send You this Cool Shirt >>>> New Relic is the only SaaS-based application performance monitoring >>>> service >>>> that delivers powerful full stack analytics. Optimize and monitor your >>>> browser, app, & servers with just a few lines of code. Try New Relic >>>> and get this awesome Nerd Life shirt! >>>> http://p.sf.net/sfu/newrelic_d2d_apr >>>> __[ g a l l e r y - d e v e l ]_________________________ >>>> >>>> [ list info/archive --> http://gallery.sf.net/lists.php ] >>>> [ gallery info/FAQ/download --> http://gallery.sf.net ] >>>> >>> >>> >> >> ------------------------------------------------------------------------------ >> Try New Relic Now & We'll Send You this Cool Shirt >> New Relic is the only SaaS-based application performance monitoring >> service >> that delivers powerful full stack analytics. Optimize and monitor your >> browser, app, & servers with just a few lines of code. Try New Relic >> and get this awesome Nerd Life shirt! >> http://p.sf.net/sfu/newrelic_d2d_apr__[ g a l l e r y - d e v e l >> ]_________________________ >> >> >> [ list info/archive --> http://gallery.sf.net/lists.php ] >> [ gallery info/FAQ/download --> http://gallery.sf.net ] >> >> >> > --001a11c329e8f4a5ef04db80633e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hey Chad and Bharat,<div><br></div><div>Thanks for the fee= dback. =C2=A0Sounds good to me - semantic tags it is. =C2=A0I just finished= redoing the templates, and the login controller appears to render exactly = like it used to, both in html and ajax modes. =C2=A0Sweet!<div> <br></div><div style>Take care,</div><div style>Shad</div></div></div><div = class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On 29 April 2013 0= 0:42, Bharat Mediratta <span dir=3D"ltr"><<a href=3D"mailto:bharat@menal= to.com" target=3D"_blank">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>+1 for using <f= ieldset> and other semantic tags. =C2=A0We've been down this road th= ree times before (G1, G2 and G3!) and in all cases keep coming back to the = value of semantic tags...</div> </div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Sun,= Apr 28, 2013 at 3:29 PM, Chad Kieffer <span dir=3D"ltr"><<a href=3D"mai= lto:[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 style=3D"word-wrap:break-word">Hey Shad,<div><br></div><div>Nice work = on combining the login routes. That simplifies things nicely.=C2=A0</div><d= iv><br></div><div>I'll always argue for keeping semantically meaningful= tags over div tags. I don't think using divs simplifies theming all th= at much. Sure, if a themer doesn't want the default border of a fieldse= t they have to override that, but it's just a few lines of CSS. I'd= also argue for the use of legend tags to label forms or form sections.</di= v> <div><br></div><div>Fieldsets group related form elements, even on the simp= lest of forms. I believe we get=C2=A0accessibility=C2=A0points, even if it&= #39;s not something users are clamoring for in Gallery.=C2=A0</div><div><br= ></div><div> My $.02.</div><div><br></div><div>- Chad</div><div><br><div><div><div><div>= On Apr 28, 2013, at 4:03 PM, Shad Laws wrote:</div><br></div></div><blockqu= ote type=3D"cite"><div><div><div dir=3D"ltr">Alright, I think I have one co= mplete example finished up - the login controller works! =C2=A0I squashed f= our routes (login/ajax, login/auth_ajax, login/html, login/auth_html) into = one (login). =C2=A0Also, I made some tweaks to Formo so we could keep all o= f our labels/errors inline (as opposed to in external message files) and au= tomatically stick in our CSRF token.<div> <br></div><div>Next step - work on the formatting. =C2=A0It seems that Gall= ery's old template used <li> elements for each input with a <f= ieldset> for each group. =C2=A0By default, Formo's templates use a &= lt;div> on everything. =C2=A0Before I rewrite them all, I thought I'= d ask: is there a reason why we should prefer one or the other? =C2=A0Using= li/fieldset seems better for backward compatibility, but using divs seems = more flexible for theming... thoughts?</div> <div><br></div><div>Take care,</div><div>Shad</div></div><div class=3D"gmai= l_extra"><br><br><div class=3D"gmail_quote">On 24 April 2013 18:42, Bharat = Mediratta <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" targe= t=3D"_blank">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>Fantastic. =C2=A0I= never liked the way we had this split up before so it's nice to see th= at Formo can streamline it for us.</div> <div><br></div><div>I've also never been happy with our form/{add,edit}= / routing - that was a framework put in place before it was clear what the = true need would be and it's only used in 9 places. =C2=A0I'd be hap= py to see that routing go away and let each controller do it in a more ad h= oc approach. =C2=A0Take a look at that while you're in there and let me= know what you think.</div> <div><br></div><div>-Bharat</div></div><div class=3D"gmail_extra"><br><br><= div class=3D"gmail_quote">On Wed, Apr 24, 2013 at 1:13 AM, Shad Laws <span = dir=3D"ltr"><<a href=3D"mailto:shad-xpYdmXCiSuZWk0Htik3J/[email protected]" target=3D"_blank">shad= @shadlaws.com</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hey everyone,<div><br></div= ><div>I'm working on getting acquainted with Formo a bit more, and it s= eems like the default, expected actions of Formo is a bit different than ho= w we were using Forge in Gallery 3.0.x.</div> <div><br></div><div>Before, we usually (but not always) had a separate cont= roller action for showing a form vs. validating a form (e.g. action_edit() = and action_save()). =C2=A0Also, it was common to have a third function gene= rate the form for us, so we ended handling the form in three places.</div> <div><br></div><div>It seems that the default, expected behavior of Formo i= s to do this in one place with one action. =C2=A0It's smart enough to f= igure out if we have post data or not, and therefore if we are in "edi= t" or "save" mode (following the example). =C2=A0An example:= </div> <div><br></div><div><font face=3D"courier new, monospace">public function a= ction_edit() {</font></div><div><font face=3D"courier new, monospace">=C2= =A0 $form =3D Formo::form(...)</font></div><div><font face=3D"courier new, = monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ->....; // build form, loa= d with default values.</font></div> <div><font face=3D"courier new, monospace"><br></font></div><div><font face= =3D"courier new, monospace">=C2=A0 if ($form->load()->validate()) {</= font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 // load= () gets the values from post/files and fills the values,</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 // then validate()= checks stuff and does nothing if the form isn't</font></div><div><font= face=3D"courier new, monospace">=C2=A0 =C2=A0 // yet sent (nothing loaded)= or adds errors if it was.</font></div> <div><font face=3D"courier new, monospace"><br></font></div><div><font face= =3D"courier new, monospace">=C2=A0 =C2=A0 // Do some more stuff... then:</f= ont></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0=C2=A0Mes= sage::success(t("Done!"));</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 // And/or:</font><= /div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 $this->red= irect("somewhere/else");</font></div><div><font face=3D"courier n= ew, monospace">=C2=A0 }</font></div> <div><font face=3D"courier new, monospace">=C2=A0=C2=A0</font></div><div><f= ont face=3D"courier new, monospace">=C2=A0 $view =3D .....;</font></div><di= v><font face=3D"courier new, monospace">=C2=A0 $view->form =3D $form;</f= ont></div> <div><font face=3D"courier new, monospace"><br></font></div><div><font face= =3D"courier new, monospace">=C2=A0 $this->response->body($view);</fon= t></div><div><font face=3D"courier new, monospace">}</font></div> <div><br></div><div>I can overload a couple Formo classes to ensure that ea= ch form contains and validates our csrf, similar to what we did with Forge.= <br></div><div><br></div><div>Does this seem like a reasonable approach? = =C2=A0Is there some other reason why we intentionally divided these up into= multiple actions before?</div> <div><br></div><div>Take care,</div><div>Shad</div></div> <br>-----------------------------------------------------------------------= -------<br> Try New Relic Now & We'll Send You this Cool Shirt<br> New Relic is the only SaaS-based application performance monitoring service= <br> that delivers powerful full stack analytics. Optimize and monitor your<br> browser, app, & servers with just a few lines of code. Try New Relic<br= > and get this awesome Nerd Life shirt! <a href=3D"http://p.sf.net/sfu/newrel= ic_d2d_apr" target=3D"_blank">http://p.sf.net/sfu/newrelic_d2d_apr</a><br>_= _[ g a l l e r y - d e v e l ]_________________________<br> <br> [ list info/archive --> <a href=3D"http://gallery.sf.net/lists.php" targ= et=3D"_blank">http://gallery.sf.net/lists.php</a> ]<br> [ gallery info/FAQ/download --> <a href=3D"http://gallery.sf.net/" targe= t=3D"_blank">http://gallery.sf.net</a> ]<br></blockquote></div><br></div> </blockquote></div><br></div> ---------------------------------------------------------------------------= ---<br>Try New Relic Now & We'll Send You this Cool Shirt<br>New Re= lic is the only SaaS-based application performance monitoring service <br> that delivers powerful full stack analytics. Optimize and monitor your<br>b= rowser, app, & servers with just a few lines of code. Try New Relic<br>= </div></div>and get this awesome Nerd Life shirt! <a href=3D"http://p.sf.ne= t/sfu/newrelic_d2d_apr__%5B" target=3D"_blank">http://p.sf.net/sfu/newrelic= _d2d_apr__[</a> g a l l e r y - d e v e l ]_________________________<div> <br><br>[ list info/archive --> <a href=3D"http://gallery.sf.net/lists.p= hp" target=3D"_blank">http://gallery.sf.net/lists.php</a> ]<br>[ gallery in= fo/FAQ/download --> <a href=3D"http://gallery.sf.net" target=3D"_blank">= http://gallery.sf.net</a> ]</div> </blockquote></div><br></div></div></blockquote></div><br></div> </blockquote></div><br></div> --001a11c329e8f4a5ef04db80633e-- --===============5561773556618493511== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr --===============5561773556618493511== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline __[ g a l l e r y - d e v e l ]_________________________ [ list info/archive --> http://gallery.sf.net/lists.php ] [ gallery info/FAQ/download --> http://gallery.sf.net ] --===============5561773556618493511==--