Both forms are based on a "search" model.
1) Search by keyword only (hence, only 1 element being "keyword")
2) Search by a few different attributes (including keyword).
Attributes are such as price, brand and make.
When constructing a search form, "form_for" will be used. Here's an
extract from one of them:
-------------------- Extract start
Both forms are based on a "search" model.
1) Search by keyword only (hence, only 1 element being "keyword")
2) Search by a few different attributes (including keyword).
Attributes are such as price, brand and make.
When constructing a search form, "form_for" will be used. Here's an
extract from one of them:
-------------------- Extract start
-------------------------------------------------------------------------------------
<% form_for :search, :url => search_path, :html => {:method => "get"}
do |f| %>
<div id="category_div">
<%= render :partial => 'search/categories' %>
</div>
<p>
<%= f.label :title_like, "Brand" %>
<%= f.text_field :brand_like %>
</p>
Now, when the page loads, there are two search forms and both of them
will have submit buttons with identical names being "search_submit".
This will obviously cause a failure in the w3c html validator due to
the identical elements appearing more than once in a page.
1) Is there any way we can specify the name of a given submit button?
2) Is there an alternative such that I can still maintain two search
forms in the same page?
> hi, guys,
>
> I have an app which has two forms on the page.
>
> Both forms are based on a "search" model.
> 1) Search by keyword only (hence, only 1 element being
"keyword")
> 2) Search by a few different attributes (including keyword).
> Attributes are such as price, brand and make.
>
> When constructing a search form, "form_for" will be used.
Here's an
> extract from one of them:
> -------------------- Extract start
>
-------------------------------------------------------------------------------------
> <% form_for :search, :url => search_path, :html => {:method
=> "get"}
> do |f| %>
> <div id="category_div">
> <%= render :partial => 'search/categories' %>
> </div>
> <p>
> <%= f.label :title_like, "Brand" %>
> <%= f.text_field :brand_like %>
> </p>
>
> ...
> <p>
> <%= f.label :title_like, "Keyword" %>
> <%= f.text_field :title_like %>
> </p>
> <p>
> <%= f.submit 'Search' %>
> </p>
> <% end %>
> -------------------- Extract end
>
-------------------------------------------------------------------------------------
>
>
> Now, when the page loads, there are two search forms and
both of them
> will have submit buttons with identical names being
"search_submit".
>
> This will obviously cause a failure in the w3c html
validator due to
> the identical elements appearing more than once in a page.
>
> 1) Is there any way we can specify the name of a given
submit button?
> 2) Is there an alternative such that I can still maintain
two search
> forms in the same page?
>
----
f.submit 'Search Categories'
f.submit 'Search Something Else'
I can confirm that
<%= f.submit "Search", :id => "a_search" %>
<%= f.submit "Search", :id => "another_search" %>
will give different id's and so keep the html valid