Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formtastic set class and id of form

How can I set the class and id attribute for the form element through semantic_form_for?

The following code:

<% semantic_form_for (@meetingsearch), :class => "new_meeting_search", :id => "meeting_search" do |f| %> 

gives me:

<form action="/meetingsearches" class="formtastic meetingsearch" id="new_meetingsearch" method="post">  
like image 729
astropanic Avatar asked Jan 12 '10 07:01

astropanic


1 Answers

This should do what you need (untested):

<% semantic_form_for @meetingsearch, :html => { :class => "new_meeting_search", :id => "meeting_search" } do |f| %> 

For clarification, semantic_form_for wraps around Rails' built in form_for, so this is exactly how you do it in regular Rails forms also:

<% form_for @meetingsearch, :html => { class => "new_meeting_search", :id => "meeting_search" } do |f| %> 
like image 69
Justin French Avatar answered Sep 28 '22 09:09

Justin French