Hi,

I hate forms. I really do :)

Forms are one of the most important things in applications, but they
are real pain most of the time. I always wanted to have some unified
form markup, easily styleable with nice look out of the box.

I've created merb plugin which provides extended builder (it's on
github: http://github.com/drogus/merb-sexy-forms , but please don't
use it now - it's in development and it's my battlefield :).

My target was to keep methods that I know and generate much more with
them. For example:

= text_field :name, :label => "Name:", :required => true, :note => "A
note"
= check_box :active, :label => "Active:"

The above code should generate inputs, wrappers and containers for
them, add required class (or html for required field) and note to text
field.

It seems great for me. It's dry, it's unified, everyone in the project
can just use text_field and can forget about remembering the
structure, classes and stuff like that. And if I need to apply some
weird styles I could just change builder, not templates in gazillion
places.

After actually using it in my project I've realized that it's good as
long as fields are relatively simple.

Consider such a field:

= text_field :name, :label => "Name:", :required => true, :class =>
"short", :after => "Something", :note => "Some really long text, that
for sure will make this line <strong>longer</strong> than it should
be", :container => { :class => "container_class" }

Long stinky hash.

At this moment I can:

1. Consider this plugin useless and began to just write haml (and I
don't want it ;-)

2. Get rid of that stinky hash from view.

It can be done in two ways.

Move hash to helper - it's good for one field, creating helper for
every longer field call would be pain...

Or.... pass a block to field:
= text_field :name do |c|
  - c[:label] = "Name"
  - c[:required] = true
  .... etc.

It's much better.

But here comes the problem -
http://github.com/drogus/merb-sexy-forms/commit/57b7b079151b47a75ad373ef53df1c594daa8ee7#L1R22
- the only way to make it work is to monkey patch some helpers. If you
have to use monkey patching in merb it's a bug, so I could just create
a ticket on lighthouse, but I don't know if I should :) It would not
change the API as &blk is optional, but still...

Is it worth it? For me yes, but I probably can't look at it
objectively. What do you think about it?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to