Design of Forms

Matt Wagner matt.wagner at redhat.com
Wed Aug 15 14:34:07 UTC 2012


On Wed, Aug 15, 2012 at 12:24:35PM +0200, Imre Farkas wrote:
> 
> I played with simple_form to get an idea of how difficult the markup
> is to implement.
> 
> Step 1: Created a new wrapper. You can find the code here:
> https://gist.github.com/bf366db929ee55af7e82
> Step 2: Created a new simple_form component for other fields e.g.
> 'note': https://gist.github.com/3358420
> Step 3: Change the default wrapper for simple_form in the
> initializer: config.default_wrapper = :conductor
> 
> After these steps, implementing a form is pretty easy:
> = simple_form_for(@post) do |f|
>   = f.input :title, :placeholder => 'placeholder',
>                     :hint => 'hint',
>                     :note => 'note'

That's pretty much perfect, IMHO. It separates style-related markup from
forms, and means that throwing together a form will result in the right
thing happening by default. I think that's exactly what we want.

> The added benefit of simple_form is that you will automatically get
> the require/optional class for the inputs for free based on the
> validations of the model (You can override them via options if
> necessary). The same applies for the maxlength attribute of the input
> field. Developers won't need to implement the markup Jarda created,
> but using a simple api call would do the magic.

I was wondering how that would work. That would be really nifty.

-- Matt



More information about the aeolus-devel mailing list