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 7565169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:05:03+00:00 2026-05-30T14:05:03+00:00

I’ve been struggling with finding the best approach to this issue for over a

  • 0

I’ve been struggling with finding the best approach to this issue for over a week now (yes, I’m a newbie). In my app, users create projects and then build relationships (“pfollow”) with their choice of plant objects in my database.

I’ve been using a collection_select styled with a dropdown Jquery select plugin called “listselect” up till now (and it works fine), but I now want to be able to feature the plant choices as images–not in a dropdown menu of any sort, but rather as a grid or in a circle of images with certain Jquery-UI effects upon click. The collection_select currently looks like this:

    <%= form_for @project.prelationships.build(:pfollowed_id =>
                                       @project_id) do |f| %>
      <%= collection_select :prelationship, :pfollower_id, Plant.all, :id,   
                            :group, {},:multiple => true,
                            :class => "listselect" %>
      <%= hidden_field_tag :project_id, @project.id %>
    <div class="actions">
      <%= f.submit "Pfollow" %>
    </div>
   <% end %> 

What I can’t figure out now is: what’s the best way to feature these plant images on my page and pass the selected plants on to the controller? I’ve been toying with four different approaches:

a) Build off a Jquery-UI Plugin like the ‘Simple Photo Manager’ or ‘Selectable-Display as Grid’ and then try to capture the li class of “ui.selected.” But if I do this, I have no idea how to pass the class of the selected object back into the collection_select, and I haven’t found a good solution online.

b) Use the html options block in collection_select to create an image select with some added Jquery <– is that even possible? I can’t find any documentation on doing this or a good plugin.

c) Feature each plant image as a unique object on the select page without collection_select and make each plant image its own “form_for image_tag” that creates the appropriate relationship instantly upon click with Ajax <– again, I’m not sure if this is possible

d) Similar to (c), make each plant image its own unique object and then when clicked, capture the ui.selected and pass it to form_for helper like this one:

    <%= form_for @project.prelationships.build(:pfollowed_id =>
                                       @project_id) do |f| %> 

but, again, I can’t figure out how I can pass the selected image into a :pfollowed_id that the form_for helper could use to pass to the controller.

Thanks in advance!

In the end, my code actually looked like this. Still have to play with the CSS and Jquery:

   <%= form_for @project.prelationships.build(:pfollowed_id =>
                                       @project_id) do |f| %>
     <%  Plant.all.each do |plant| %>
       <%= label_tag "prelationship[pfollower_id][]", plant.name %>
       <%= check_box_tag "prelationship[pfollower_id][]", plant.id %>
     <% end %>  
   <%= hidden_field_tag :project_id, @project.id %>
   <%= f.submit "Pfollow" %>
   <% end %> 
  • 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-30T14:05:05+00:00Added an answer on May 30, 2026 at 2:05 pm

    There may be a lot of UI-magic you could possibly implement using Jquery etc, but I’ll suggest a simple way to replace drop downs with check-boxes –

    <%= form_for(prelationship) do |f| %>
      <%  Plant.all.each do |plant| %>
        <%= label_tag plant.name %>
        <%= check_box_tag "prelationship[pfollower_ids]" %>
      <% end %>
    <%= end %>
    

    This code creates a checkbox and a corresponding label for each of the plants, and when the form is posted, params[:prelationship][:pfollower_ids] contains a list of all the pfollower_ids

    To enhance the UI further, you can replace the label with an image_tag, and add some Js to check/uncheck the corresponding checkboxes every-time the image label is clicked. Then, maybe if you want to remove checkboxes, you can hide them with css, or use hidden_field_tag to remove them entirely.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.