Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 847803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:50:44+00:00 2026-05-15T06:50:44+00:00

I have created the following select using the option_groups_from_collection_for_select form helper in Rails as

  • 0

I have created the following select using the option_groups_from_collection_for_select form helper in Rails as part of a search feature.

<select>
  <option>All Categories</option>
  <optgroup label="Garden">
    <option value="1">Garden Accessories</option>
    <option value="2">Gardens Random</option>
    <option value="3">Sheds</option>
    <option value="4">Playsets</option>
  </optgroup>
<select> 

The problem is, I want a user to be able to search all of the “Garden” sub-categories at once, but as “Garden” is a label, this does not work, it forces the user to pick one of the sub-categories.

One idea is to somehow be able to add a <option>All Garden<option> tag within the optgroup, but not sure how to inject this into the list.

My search form has no room to add a second sub-category select box.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:50:44+00:00Added an answer on May 15, 2026 at 6:50 am

    I figured this out,

    In the method I am using to get the child-categories for the optgroup, I just append the current model / category to the array of child categories returned from the AR find call and it works a treat.

    .unshift(self.dup)
    

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code using QuickForm that creates a select widget with the following: $form->addElement(
I have created the following form with qt designer. I added a Add Files
To select all Scheduling s which are active, I have the following code: var
I have a mini form that consists of all select boxes and checkbox lists.
I have created a PHP code to echo the following div <div id=main_catsel> <select
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
I have created following rule in the .htaccess file located at the root of
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I have created the following C library for reading an image: typedef struct {
I have created the following project structure for my new asp.net mvc project any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.