0

I have a three tables Plan, Channel and ChannelCategory. While creating a new Plan I want to select multiple channel_categories and based on that I want to select multiple channels. Please provide me the solution.

1
  • Can you please post your code ? Commented May 31, 2016 at 6:14

1 Answer 1

1

For multiple select you could do something like this

<%= f.select(:channel_category, [['Sports', 'sports'],
                                 ['Entertainment', 'entertainment'],
                                 ['Music', 'music']
                                ],{ :prompt => "Please select"},
                                { :multiple => true, :size => 3 }) %>

Edit:

then for channels you'll also need multiple select

<%= f.select(:channels, [['Channel1', 'ch1'],
                                 ['Channel1', 'ch2'],
                                 ['Channel1', 'ch3']
                                ],{ :prompt => "Please select"},
                                { :multiple => true, :size => 3 }) %>

And if you need channels after selecting channel_categories maybe you could try with conditional validations.

I had similar problem so I solved it with conditional validations.

Sign up to request clarification or add additional context in comments.

6 Comments

I do not get you why I need nested form.
I am creating a new Plan in which I can select multiple channel categories as Sports, Entertainment, Music etc. and whichever are selected on that basis I want to select multiple channels based on above selected channel categories.
Can you please guide me as it is working for single channel category.
But I want to get channels for multiple channel categories. Hope now you get my requirement.
This is I have done but on selecting channel category I want channels of that channel category to be come in another drop-down and I can select multiple channels in that second drop-down.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.