Hi Greg,<div><br></div><div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
For custom form design, do you just want a different html structure (paragraphs instead of table rows)?</blockquote><div><br></div><div>No, having an auto generated structure will never be able to handle the various requirements I get for forms.  Having a system that auto generates scaffolding for you is a nice to have, having a system that only gives you auto generated forms is about the same as painting yourself into a corner.</div>
<div><br></div><div>For security in <a href="http://asp.net">asp.net</a> mvc you would have a form model, or what is commonly referred to as a view model.  This model only has fields that you wish to be exposed.  On form submission you would then move the desired fields to your domain/data model (this can be simplified by using a project like automapper which uses reflection and configuration to copy fields).  The validation is also associated with the form/view model.</div>
<div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
I didn&#39;t see a full controller example in your F# code- how do you securely update your model?</blockquote><div><br></div><div>The full submit action sample is generally very small due to a lot of the plumbing of <a href="http://asp.net">asp.net</a> mvc being hidden.</div>
<div><br></div><div>In F# it would look something like this.</div><div><br></div><div>type MyController() =</div><div>    inherit Controller()</div><div><br></div><div>    member this.MySubmitAction(form:MyFormModel) =</div>
<div>        if ModelState.IsValid = false then</div><div>            base.View(&quot;MyFormView&quot;, form)</div><div>        else</div><div>            let domainModel = moveFormModelToDomainModel form</div><div>            save domainModel</div>
<div>            redirectToThankYouPage ()</div><div><br></div><div>By the time you enter the above method you will already have your form validated with the ModelState being populated with your validation errors.</div><div>
<br></div><div>I don&#39;t really believe that a lot of this is transferable to haskell, due to the lack of reflection and general constraints that haskell puts on you.  I&#39;ve theorized about how I would go about creating much the same thing in haskell, but to get the javascript conversion you&#39;d have to write a template haskell -&gt; javascript converter (which would probably be quite a bit of effort).  For custom layout you&#39;d probably also have to use template haskell to specify where you want form fields to render.</div>
<div><br></div><div>Anyway, these are obviously just my opinions and you can take them or leave them.  I&#39;d really love to be able to use yesod and haskell for the type of work I do, but I can&#39;t see doing so until it has what i consider a robust forms solution that doesn&#39;t add a lot of friction to my development.</div>
<br><div class="gmail_quote">On Wed, Jun 1, 2011 at 9:58 AM, Greg Weber <span dir="ltr">&lt;<a href="mailto:greg@gregweber.info">greg@gregweber.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>Hi Justin,</div><div><br></div><div>It is great to have feedback from an F# perspective.</div><div><br></div><div>For custom form design, do you just want a different html structure (paragraphs instead of table rows)? If so, it is easy enough to create a new form renderer for a different structure. Easier css manipulation should help to design custom forms. It seems that the main problem would be if you want to insert some extra structure, like a paragraph, in between some form fields. You can build custom forms with the monadic form builder, but it doesn&#39;t handle error propagation automatically. We should see how your example translates here.</div>


<div><br></div><div>As another example of validations, Rails supports complex validation logic by placing it entirely in the model instead of the form (but it gets fed back to the form). There is at least one project now to extend that validation logic to the client side.</div>


<div><br></div><div>In Rails, like the F# example, it is easy to build custom forms because they are placed in your view. However, this along with Rails mass attributes updates (assign every form field to the model instead of listing out every attribute to assign) is a major cause of security problems- now you have to block a malicious user from submitting fields that you didn&#39;t want to expose in your form. By building the form outside of the view, we automatically have a data structure that determines which fields can be assigned. I didn&#39;t see a full controller example in your F# code- how do you securely update your model?</div>


<div><br></div><div>Thanks,</div><div>Greg Weber</div><div><div></div><div class="h5"><div><br><div><div class="gmail_quote">On Wed, Jun 1, 2011 at 6:57 AM, Justin Greene <span dir="ltr">&lt;<a href="mailto:justin.j.greene@gmail.com" target="_blank">justin.j.greene@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>The custom form design and variable length list stuff is default <a href="http://asp.net" target="_blank">asp.net</a> mvc.</div>


<div><br></div><div>The validation stuff I ended up writing myself using F# quotations, it goes a couple steps farther than what I even mentioned as it converts the F# to javascript so you get server side validation and client side validation for free.  Here&#39;s the github project: <a href="https://github.com/jgreene/FSharp.Javascript.Mvc" target="_blank">https://github.com/jgreene/FSharp.Javascript.Mvc</a> and you can read more about it here: <a href="http://justsimplecode.com/" target="_blank">http://justsimplecode.com/</a></div>



<div><br></div><div><a href="https://github.com/jgreene/FSharp.Javascript.Mvc" target="_blank"></a>There is not much documentation, and there is some complexity to setting up a framework to do something like this, but it&#39;s very doable.</div>


<div><div></div><div>
<div><br></div><div><br><br><div class="gmail_quote">On Wed, Jun 1, 2011 at 8:44 AM, Mark Bradley <span dir="ltr">&lt;<a href="mailto:barkmadley@gmail.com" target="_blank">barkmadley@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>On Wed, Jun 1, 2011 at 11:32 PM, Justin Greene<br>
&lt;<a href="mailto:justin.j.greene@gmail.com" target="_blank">justin.j.greene@gmail.com</a>&gt; wrote:<br>
&gt;&gt; * Forms package: It&#39;s been rewritten, but hasn&#39;t really had much input<br>
&gt;&gt; from others. Now&#39;s the time to speak up if you have any opinions on<br>
&gt;&gt; it. The code is available on Hackage.<br>
&gt;<br>
&gt; List of things that should be inside a forms package in my opinion.<br>
&gt; Custom Design: Form layout should be simple to customize and not be based<br>
&gt; around auto generating tables (if both are possible then of course the later<br>
&gt; can be used).<br>
&gt; Variable length lists: It should be possible to add form elements on the<br>
&gt; client side and bind them on the server side.  An example of this would be a<br>
&gt; list of addresses.  A programmer should be able to add a new address widget<br>
&gt; client side without problems when binding server side.<br>
&gt; Validation:  Complex validation scenarios should be simple and should fit<br>
&gt; into the normal validation pipeline.  An example would be validating that if<br>
&gt; a checkbox is selected then a textbox becomes required.<br>
&gt; All validation errors should display around the same time, e.g. if a type<br>
&gt; validator fires it should not prevent other validators from firing after it<br>
&gt; unless those validators depend upon that type data.<br>
&gt; These are just my thoughts based upon my experiences writing forms.  I can&#39;t<br>
&gt; really utilize any framework that doesn&#39;t implement these features for the<br>
&gt; types of projects I do.<br>
&gt; If you need any more details/clarification I&#39;d be happy to help.<br>
<br>
</div>out of curiosity, which frameworks have you worked with that have some<br>
or all of these features (particularly the complicated validation)?<br>
<div><div></div><div><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, May 30, 2011 at 3:41 PM, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com" target="_blank">michael@snoyman.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; It&#39;s been about a month since the 0.8 release of Yesod. In the release<br>
&gt;&gt; announcement[1], we laid out some goals. Let&#39;s take a chance to<br>
&gt;&gt; analyze where we&#39;re at:<br>
&gt;&gt;<br>
&gt;&gt; * Documentation: Still improving as always. In particular, the new<br>
&gt;&gt; Yesod site is making it much easier for me to write new content (I<br>
&gt;&gt; have a few things on my local system that can finally go up).<br>
&gt;&gt;<br>
&gt;&gt; * Static file caching headers: Implemented by Greg Weber. We&#39;ll likely<br>
&gt;&gt; be making some API changes to handle embedded files, though that<br>
&gt;&gt; discussion deserves its own blog post.<br>
&gt;&gt;<br>
&gt;&gt; * Other template types: For Hamlet 0.9, we&#39;re going to be splitting<br>
&gt;&gt; Julius/Coffeescript into their own package, and juggling the type<br>
&gt;&gt; signature for Coffeescript a bit. At that point, it should be<br>
&gt;&gt; straightforward to embed Coffeescript directly into a Yesod app, just<br>
&gt;&gt; like Julius is today.<br>
&gt;&gt;<br>
&gt;&gt; * Something like require.js: This is something we haven&#39;t started on<br>
&gt;&gt; yet. I&#39;ll likely start looking into it this week. Additionally, I know<br>
&gt;&gt; that a lot of my sites (jQuery powered) have numerous onload calls per<br>
&gt;&gt; page; I think we can try to make that more efficient as well. I would<br>
&gt;&gt; especially like people&#39;s input on this point.<br>
&gt;&gt;<br>
&gt;&gt; * i18n: The solution is written, and I&#39;m using it in production. At<br>
&gt;&gt; this point, I&#39;d call it beta quality, and I&#39;d appreciate input.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; * Embedded objects in MongoDB: No work done yet.<br>
&gt;&gt;<br>
&gt;&gt; * Performance improvements: Nothing in particular. If you have any<br>
&gt;&gt; examples of Yesod performing badly, please let us know.<br>
&gt;&gt;<br>
&gt;&gt; The goal is for Yesod 0.9 to be feature complete, and for 1.0 to be a<br>
&gt;&gt; fairly stable API. From the list above, my two priorities are better<br>
&gt;&gt; Javascript loading (require.js) and static file serving. However,<br>
&gt;&gt; there&#39;s one other major issue we need to address: the devel server.<br>
&gt;&gt; Unfortunately, it doesn&#39;t work very well at all right now. Thankfully,<br>
&gt;&gt; &quot;yesod build&quot; *does* work very well, and for my development I&#39;ve<br>
&gt;&gt; fallen back to simply &quot;yesod build &amp;&amp; ./dist/build/myapp/myapp&quot; on the<br>
&gt;&gt; command line. My guess is that we&#39;re 90% of the way there on &quot;yesod<br>
&gt;&gt; devel&quot;. This is a project that isn&#39;t tightly bound to the rest of the<br>
&gt;&gt; API work, and would be very approachable for someone trying to get<br>
&gt;&gt; started on Yesod development. If you&#39;re interested in helping out<br>
&gt;&gt; here, please let me know.<br>
&gt;&gt;<br>
&gt;&gt; I have no specific timeframe in mind for Yesod 0.9. As it stands now,<br>
&gt;&gt; it looks like the 0.9 release will involve almost no API breakage,<br>
&gt;&gt; which is a very good sign. But if you have any ideas you&#39;d like to<br>
&gt;&gt; contribute, I&#39;d recommend getting them in in the next week or two.<br>
&gt;&gt;<br>
&gt;&gt; Michael<br>
&gt;&gt;<br>
&gt;&gt; [1] <a href="http://www.yesodweb.com/blog/2011/4/announcing-yesod-0-8" target="_blank">http://www.yesodweb.com/blog/2011/4/announcing-yesod-0-8</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; web-devel mailing list<br>
&gt;&gt; <a href="mailto:web-devel@haskell.org" target="_blank">web-devel@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; web-devel mailing list<br>
&gt; <a href="mailto:web-devel@haskell.org" target="_blank">web-devel@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
-barkmadley<br>
sent from an internet enabled device<br>
</font></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
web-devel mailing list<br>
<a href="mailto:web-devel@haskell.org" target="_blank">web-devel@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
<br></blockquote></div><br></div></div>
</div></div></blockquote></div><br></div>