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

  • Home
  • SEARCH
  • 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 4572082
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:35:45+00:00 2026-05-21T19:35:45+00:00

When a user adds an event, they need to be able to add Bands

  • 0

When a user adds an event, they need to be able to add Bands from the “bands” table to the event. It’s already all set up with the HABTM, and I have it working when I hard-code multiple select boxes to the page.

The problem is – I’d like to just have one select box, then an “add another band” button – which would add another select input with the list of bands – and so on – as many as they’d like.

I found this post: Add and remove form fields in Cakephp which explains how to add a field dynamically… my issue is, the list of bands is huge, and changes regularly, so I can’t imagine this working for me.

Any ideas on the best way to go about this? – Adding a select input dynamically that’s populated with a list of bands from my database? Ajax maybe? (I’ve no idea how to do ajax with cake yet) Ajax seems ok, but do I really want to pull a list of bands every time the user clicks the “add a band” button? Maybe that’s ok?

Any help/direction is greatly appreciated. Code example would be GREAT, but if nothing else, a nudge in the right direction would be very helpful.

  • 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-21T19:35:46+00:00Added an answer on May 21, 2026 at 7:35 pm

    You could use a single select input with an ‘add band’ button. When the user hits ‘add band’, catch the event with javascript, copy the selected band to a list (visually), and add the id to a hidden input (to be used when the form is submitted). jQuery/CakePHP example below.

    <ul id='band_list'></ul>
    <?php echo $form->create('Event', array('id'=>'event_form'));?>
    <?php echo $form->input('band_ids', array('type'=>'hidden', 'id'=>'band_ids')); ?>
    <?php echo $form->input('bands', array('type'=>'select', 'options'=>$bands, 'id'=>'bands_selector')); ?>
    <button id='add_band'>Add Band</button>
    
    <script type='text/javascript'>
        var band_count = 0;
        $('#add_band').click(function(event) {
            event.preventDefault();
            $('<li>' + $('#bands_selector option:selected').text() + '</li>').appendTo('#band_list');
            $('<input type="hidden" name="data[Band][Band]['+band_count.toString()+']" value="'+$("#bands_selector option:selected").val()+'">').appendTo('#event_form');
            band_count++;
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login.jsp page which contains a login form. Once logged in the
This is beyond both making sense and my control. That being said here is

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.