Search code examples
rubyhamlpadrino

Is This a Bug? Can't Specify form id using form_for in Padrino


I have this form_for tag:

= form_for @food, :autocomplete => "off", :id => "food" do |f|

This is the tag it generates:

<form action-autocomplete="off" action-id="food" accept-charset="UTF-8" method="post">

How can I specify the html form id attribute from the form_for tag? Note that padrino has added an "action" before the autocomplete attribute as well.

This looks like a bug to me. I'm using version 0.12.2 of Padrino.


Solution

  • You need to specify the URL as the second parameter in case you want to use a custom id. The code should be:

    = form_for @food, '/path/to/create/', id: 'food' do |f|
    

    code for form_for

    This is a similar pattern adopted from Rails. In Rails, however, you don't have to specify the URL as the second argument and the HTML-based settings go in to the html option key. Worth opening an issue for this.