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? thank you. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig White
2010-Mar-17 03:51 UTC
Re: how do you manually specify the name of a submit button?
On Tue, 2010-03-16 at 20:44 -0700, ct9a wrote:> 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'' Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gordon Yeong
2010-Mar-17 03:54 UTC
Re: how do you manually specify the name of a submit button?
Thanks craig but my mistake, guys. I meant the "id" attribute. Hence, we''ll get two submit buttons: <input id="search_submit" name="commit" type="submit" value="Search" /> (first form) <input id="search_submit" name="commit" type="submit" value="Search" /> (second form) On 17 March 2010 14:51, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> On Tue, 2010-03-16 at 20:44 -0700, ct9a wrote: > > 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'' > > Craig > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Loganathan Ganesan
2010-Mar-17 04:14 UTC
Re: how do you manually specify the name of a submit button?
Gordon Yeong wrote:> Thanks craig but my mistake, guys. > > I meant the "id" attribute. > > Hence, we''ll get two submit buttons: > > <input id="search_submit" name="commit" type="submit" value="Search" > /> (first form) > > <input id="search_submit" name="commit" type="submit" value="Search" > /> (second form)Dear friend, Why can''t use "submit_tag" in both partial and in the current form ? While using it , it won''t have this id attribute. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gordon Yeong
2010-Mar-17 04:15 UTC
Re: Re: how do you manually specify the name of a submit button?
Smart idea! thank you. I will try it out and revert. Cheers! On 17 March 2010 15:14, Loganathan Ganesan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > Dear friend, > > Why can''t use "submit_tag" in both partial and in the current > form ? While using it , it won''t have this id attribute. > -- > Posted via http://www.ruby-forum.com/. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Problem solved. Thanks, Loganathan . W3C html validator is happy with the output generated. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Mar-17 09:12 UTC
Re: how do you manually specify the name of a submit button?
On 17 March 2010 03:54, Gordon Yeong <anexiole-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks craig but my mistake, guys. > > I meant the "id" attribute. > > Hence, we''ll get two submit buttons: > > <input id="search_submit" name="commit" type="submit" value="Search" /> > (first form) > > > <input id="search_submit" name="commit" type="submit" value="Search" /> > (second form)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 Colin> > > > > > > On 17 March 2010 14:51, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote: >> >> On Tue, 2010-03-16 at 20:44 -0700, ct9a wrote: >> > 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'' >> >> Craig >> >> >> -- >> This message has been scanned for viruses and >> dangerous content by MailScanner, and is >> believed to be clean. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gordon Yeong
2010-Mar-17 10:26 UTC
Re: how do you manually specify the name of a submit button?
bravo. another brilliant reply On 17 March 2010 20:12, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 17 March 2010 03:54, Gordon Yeong <anexiole-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Thanks craig but my mistake, guys. > > > > I meant the "id" attribute. > > > > Hence, we''ll get two submit buttons: > > > > <input id="search_submit" name="commit" type="submit" value="Search" /> > > (first form) > > > > > > <input id="search_submit" name="commit" type="submit" value="Search" /> > > (second form) > > 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 > > Colin > > > > > > > > > > > > > > > On 17 March 2010 14:51, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote: > >> > >> On Tue, 2010-03-16 at 20:44 -0700, ct9a wrote: > >> > 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'' > >> > >> Craig > >> > >> > >> -- > >> This message has been scanned for viruses and > >> dangerous content by MailScanner, and is > >> believed to be clean. > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Ruby on Rails: Talk" group. > >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > >> For more options, visit this group at > >> http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.