# Quick ruby-powered html-forms?

**URL:** <https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803>\
**Category:** Ruby\
**Created:** [January 22, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803 "2008-01-22T12:40:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 22, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/1 "2008-01-22T12:40:47Z")

</div>

I am certain someone has made a solution for quickly creating forms with  
ruby. Any ideas? (other than installing rails)

Thanks

Casimir

---

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 22, 2008, 1:30pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/2 "2008-01-22T13:30:32Z")

</div>

2008/1/22, Casimir :

> I am certain someone has made a solution for quickly  
> creating forms with ruby. Any ideas? (other than installing rails)

You’ve got plenty templating systems (ERB, Markaby, Haml…),  
to name a few. There’s also the HtmlExtension module in cgi lib.

– Jean-François.

---

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 23, 2008, 1:27am UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/3 "2008-01-23T01:27:53Z")

</div>

Casimir wrote:

> I am certain someone has made a solution for quickly creating forms with  
> ruby. Any ideas? (other than installing rails)
> 
> Thanks
> 
> Casimir

Believe it our not, this is still something that seems to be missing  
even in rails. Forms can be built from eRB or other template libraries,  
but that still requires some fairly close interaction with the nuts and  
bolts of the form especially if you want more then just the default  
types.

This is an area where the separation of content from presentation is  
still a real challenge. It should be possible to describe what data one  
wants from the use in one place and make decisions about how to ask for  
that data in another. If you have any luck with this let us know.

StarTrader

P.S. This inspired a slightly more length blog post:  
[http://startrader.wordpress.com/2008/01/22/towards-a-better-way-to-build-forms/](http://startrader.wordpress.com/2008/01/22/towards-a-better-way-to-build-forms/)

---

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 23, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/4 "2008-01-23T19:01:20Z")

</div>

On 23 Jan 2008, at 13:50, Casimir wrote:

> How to take the pain away from form writing? How to bring back the  
> POWER? How to avoid dealing with minute form details while trying  
> to build proper apps/services?

> Personally, I am just trying to find the simplest, most intuitive (-
> 
> > fastest) way to create html code for forms. Styling  
> > (presentation) happens entirely in css so it has nothing to do with  
> > form content. So I think you have a slight misinterpretation there.

> More than words… is what I would like to see… URLs.

If you’re using Rails you should look into form builders. When you  
create a form like this:

\<% form\_for @project do |f| %\>  
\<%= f.text\_field :name %\>  
…  
\<%= f.submit %\>  
\<% end %\>

…you are using an instance of Rails’ form builder (in the f  
variable): ActionView::Helpers::FormBuilder.

I recommend writing your own form builder to generate exactly the  
HTML you want.

Here are a couple of custom form builders packaged as plugins:

[http://svn.danwebb.net/external/rails/plugins/enhanced\_form\_builder/](http://svn.danwebb.net/external/rails/plugins/enhanced_form_builder/)  
[http://opensource.airbladesoftware.com/trunk/plugins/](http://opensource.airbladesoftware.com/trunk/plugins/)  
air\_budd\_form\_builder/

Regards,  
Andy S.

---

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 23, 2008, 2:50pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/5 "2008-01-23T14:50:46Z")

</div>

Starr T. kirjoitti:

> Casimir wrote:
> 
> > I am certain someone has made a solution for quickly creating forms with  
> > ruby. Any ideas? (other than installing rails)

Thanks for answers, even if no-one so far has presented “the winning  
solution”.

How to take the pain away from form writing? How to bring back the  
POWER? How to avoid dealing with minute form details while trying to  
build proper apps/services?

Jean-FranÃ§ois TrÃ¢n kirjoitti:

> You’ve got plenty templating systems (ERB, Markaby, Haml…),  
> to name a few. There’s also the HtmlExtension module in cgi lib.

Thank you. To nitpick, you didn’t really answer my question, but the  
question “what kind of templating systems are there”. I didnt ask for a  
templating system 🙂 Some would be suitable for what I was asking for.  
Haml and Hpricot are now under my investigative gaze…

> Believe it our not, this is still something that seems to be missing  
> even in rails. Forms can be built from eRB or other template libraries,  
> but that still requires some fairly close interaction with the nuts and  
> bolts of the form especially if you want more then just the default  
> types.

> This is an area where the separation of content from presentation is  
> still a real challenge.

To nitpick, I dont think this is the problem, you have misinterpreted my  
question or the concept of content.

Personally, I am just trying to find the simplest, most intuitive (-\>  
fastest) way to create html code for forms. Styling (presentation)  
happens entirely in css so it has nothing to do with form content. So I  
think you have a slight misinterpretation there.

> It should be possible to describe what data one  
> wants from the use in one place and make decisions about how to ask for  
> that data in another. If you have any luck with this let us know.

Now this idea I like. Wham! Blam! Thank you mam!

More than words… is what I would like to see… URLs.

Thanks  
Csmr

---

<div class="post-metadata">

**Author:** ![Casimir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@Casimir](https://www.ruby-forum.com/u/Casimir)\
**Post date:** [January 23, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/quick-ruby-powered-html-forms/126803/6 "2008-01-23T20:37:04Z")

</div>

On Wed, 23 Jan 2008, Casimir wrote:

> Personally, I am just trying to find the simplest, most intuitive (-\>  
> fastest) way to create html code for forms. Styling (presentation) happens  
> entirely in css so it has nothing to do with form content. So I think you  
> have a slight misinterpretation there.

Styling isn’t 100% an issue of CSS because of two factors.

1. Any specifics regarding ids or classes to be applied to particular  
form  
elements have to appear in the HTML.

2. Any pecularities regarding the form structure, which ultimately  
affect  
it’s appearance in fundamental ways that CSS can’t influence, is also  
part  
of the HTML.

So, given those two things, here’s how I tend to deal with form  
generation  
in IOWA ([iowa.swiftcore.org](http://iowa.swiftcore.org)):

 Choose a number 

This keeps all of the low level details about managing the form out of  
the  
developer’s hair. The developer just lays out the structure, and  
expects  
that when the submit button is pressed, do\_something() is called, and  
the  
number that was selected will be passed to the number=() accessor.

Kirk H.
