0

I have requirement to save data data in multiple dropdowns with master submit button and save individual dropdowns with its specific submit button. the image explains the scenario

enter image description here

and sample code for the form looks like this now i have submit button above which should read all dropdown values and send to cakephp action.can any body suggest me some solutions on how to do this.JavaScript can do this but i do not know how to call cakephp actions from javascript and pass data to them.

<?php  foreach ($epaProperties as $epaProperty): ?>
                     <?php  ?>  
                        <div class="span4"> 
                            <div class="detail2n"> 
                                <div class="utility-address"> 
                                  <address class="mb0">
                                    <b class="txtgreen"> <?php echo $epaProperty['EpaProperty']['name'] ?></b><br>
                                  <?php echo $epaProperty['EpaProperty']['property_id'] ?><br>
                                  </address>
                                </div>
                            </div>
                        </div>
                        <div class="span4"> 
                            <div class="utility-field"> 
                                <div class="row-fluid"> 
                                    <div class="input text">
                                       <?php echo $this->Form->create('EpaPropertySync');?>
                                      <?php echo $this->Form->input('epa_property_id', array('type' => 'hidden', 'value' =>$epaProperty['EpaProperty']['property_id'] )); ?>
                                      <?php echo $this->Form->input('gpsf_property_id', array('class'=>'span12 mb0','empty'=>'--select--', 'type' => 'select','label'=>false,'options' =>$PropertyAndSpace,'default'=>$epaProperty['EpaPropertySyncList']['gpsf_property_id'])); ?>

                                        <?php echo $epaProperty['EpaPropertySyncList']['DateCreated']; ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                         <div class="span4"> 
                            <div class="utility-field"> 
                                <div class="row-fluid"> 
                                    <div class="input text">

                                           <button type="submit" class="btn-flatgreen autoWidth"> Sync Property Data Now </button> 
                                           <?php echo $this->Form->end(); ?> 
                                    </div>
                                </div>
                            </div>
                        </div>
    <?php endforeach; ?>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Desi_Coder
  • 13
  • 6

1 Answers1

0

One function will have to read all the fields and submit them via post and the other one needs to submit only the single field when the button is clicked. So you have to bind the JS calls to the right scope and only submit what you need.

but i do not know how to call cakephp actions from javascript and pass data to them

That's just regular HTTP POST/GET. The only difference is that JS sends the request. Use whatever methods your JS lib provides $.ajax in jquery AFAIR.

Search here or on Google for "ajax post", "jquery submit form" and similar keywords. You'll have to learn how AJAX works now.

jQuery Ajax POST example with PHP

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66