Re: More thoughts on Forge->Formo conversion

Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> Sat, 27 Apr 2013 13:20:59 +0200
Newsgroups gmane.comp.web.gallery.devel
Message-ID <CA+z51A5EQ_SZ=V4UjzBxWspY3CP3c+iahf2zc3GNwoceQfyQXg@mail.gmail.com>
--===============1097943558333692405==
Content-Type: multipart/alternative; boundary=089e013d173aca4e4404db55d9ec

--089e013d173aca4e4404db55d9ec
Content-Type: text/plain; charset=UTF-8

I haven't dug too deeply into this piece of the puzzle yet, but my initial
thought is to still leave these as two separate action routes.  This seems
to mirror what we use in many other places, where each of the CRUD
functions has an independent route, which maps pretty easily to ORM, SQL,
REST, etc. functions.  Seem reasonable?

Shad


On 26 April 2013 20:39, Chad Kieffer <[email protected]> wrote:

> +1 from me, too. For clarity, will separate action routes be kept or will
> add/edit be replaced with something like save?
>
> On Apr 24, 2013, at 10:42 AM, 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 ]
>
>

--089e013d173aca4e4404db55d9ec
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I haven&#39;t dug too deeply into this piece of the puzzle=
 yet, but my initial thought is to still leave these as two separate action=
 routes. =C2=A0This seems to mirror what we use in many other places, where=
 each of the CRUD functions has an independent route, which maps pretty eas=
ily to ORM, SQL, REST, etc. functions. =C2=A0Seem reasonable?<div>

<br></div><div style>Shad</div></div><div class=3D"gmail_extra"><br><br><di=
v class=3D"gmail_quote">On 26 April 2013 20:39, Chad Kieffer <span dir=3D"l=
tr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a>&gt;</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"auto"><div>+1 from me, too. For =
clarity, will separate action routes be kept or will add/edit be replaced w=
ith something like save?</div>

<div><br>On Apr 24, 2013, at 10:42 AM, Bharat Mediratta &lt;<a href=3D"mail=
to:[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<=
br><br></div><div><span></span></div><blockquote type=3D"cite"><div><div di=
r=3D"ltr">

<br><div>Fantastic. =C2=A0I never liked the way we had this split up before=
 so it&#39;s nice to see that Formo can streamline it for us.</div><div><br=
></div><div>I&#39;ve also never been happy with our form/{add,edit}/ routin=
g - that was a framework put in place before it was clear what the true nee=
d would be and it&#39;s only used in 9 places. =C2=A0I&#39;d be happy to se=
e that routing go away and let each controller do it in a more ad hoc appro=
ach. =C2=A0Take a look at that while you&#39;re in there and let me know wh=
at 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">&lt;<a href=3D"mailto:shad-xpYdmXCiSuZWk0Htik3J/[email protected]" target=3D"_blank">shad=
@shadlaws.com</a>&gt;</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&#39;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&#39;s smart enough to f=
igure out if we have post data or not, and therefore if we are in &quot;edi=
t&quot; or &quot;save&quot; 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 -&gt;....; // 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-&gt;load()-&gt;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&#39;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(&quot;Done!&quot;));</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-&gt;red=
irect(&quot;somewhere/else&quot;);</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-&gt;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-&gt;response-&gt;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 &amp; We&#39;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, &amp; 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 --&gt; <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 --&gt; <a href=3D"http://gallery.sf.net" target=
=3D"_blank">http://gallery.sf.net</a> ]<br></blockquote></div><br></div>
</div></blockquote><blockquote type=3D"cite"><div><span>-------------------=
-----------------------------------------------------------</span><br><span=
>Try New Relic Now &amp; We&#39;ll Send You this Cool Shirt</span><br><span=
>New Relic is the only SaaS-based application performance monitoring servic=
e </span><br>

<span>that delivers powerful full stack analytics. Optimize and monitor you=
r</span><br><span>browser, app, &amp; servers with just a few lines of code=
. Try New Relic</span><br><span>and get this awesome Nerd Life shirt! <a hr=
ef=3D"http://p.sf.net/sfu/newrelic_d2d_apr" target=3D"_blank">http://p.sf.n=
et/sfu/newrelic_d2d_apr</a></span></div>

</blockquote><blockquote type=3D"cite"><div><span>__[ g a l l e r y - d e v=
 e l ]_________________________</span><br><span></span><br><span>[ list inf=
o/archive --&gt; <a href=3D"http://gallery.sf.net/lists.php" target=3D"_bla=
nk">http://gallery.sf.net/lists.php</a> ]</span><br>

<span>[ gallery info/FAQ/download --&gt; <a href=3D"http://gallery.sf.net" =
target=3D"_blank">http://gallery.sf.net</a> ]</span></div></blockquote></di=
v></blockquote></div><br></div>

--089e013d173aca4e4404db55d9ec--


--===============1097943558333692405==
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
--===============1097943558333692405==
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 ]
--===============1097943558333692405==--