I'm new to Codeigniter and hope to learn best practices as I go. I currently have a table generated by DB.
HTML Table:

<tr>
    <td>
      <a class="galName" href="#myModal" data-toggle="modal" >
        <?php echo $gal['name']; ?>
      </a>
    </td>
    <td>
      <?php echo $gal['clientName']; ?>
    </td>
</tr>
<?php endforeach; ?>

The Modal:

<div class="modal fade hide modal-creator" id="myModal" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Edit Gallery</h3>
    </div>
    <div class="modal-body"><?php echo form_open('url'); ?>

    <div class="row">
        <div class="span5">
            <?php print_r($galleryName); ?>
            <div class="control-group">
                <?php
                    $galleryName = array(
                        'id'            => 'galleryName',
                        'name'          => 'galleryName',
                        'placeholder'   => 'Gallery Name',
                        'required'      => 'required',
                    );
                    echo form_label('Gallery Name:', 'galleryName');
                    echo form_input($galleryName);
                ?>
            </div><!-- /control-group -->
       </div><!--/span5-->
   </div><!--/row-->
</div><!-- /modal-body -->

<div class="modal-footer">
    <!-- <p class="span3 resize">The following images are sized incorrectly. Click to edit</p> -->
    <a href="javascript:;" class="btn" data-dismiss="modal">Close</a>
    <a href="javascript:;" class="btn btn-primary">Next</a>
</div>

The link opens a bootstrap modal to which I want to pass the gallery data. I know I can pass the data through jQuery, but is it possible to keep this modal in the MVC framework, and if so, how does one call the controller via the modal link?

Thank you very much for your assistance, and I would be delighted to accept any suggestions for CodeIgniter resources. I'm currently working through the Nettuts videos, which are dated, as well as the user guide.

Hello! You would need to use AJAX (you can do it through jQuery) to send an xhr request.

If you are talking about to pass the data like <?php echo $gal['name']; ?> and <?php echo $gal['clientName']; ?> to modal, then this is possible.

    <?php
    $name = $gal['name']; 
    $client = $gal['clientName']; 
    ?>
    <a href="<?php echo base_url("your_controller_name/?name=".$name."&client=".$client);?>" data-toggle="modal" data-target="#myModal" data-backdrop="static" data-keyboard="false" id="mybtn"><?php echo $gal['name']; ?></a>

If you are talking about passing the form data of modal to next page without refresh then you will need to use AJAX.

devphp, I interpreted their question how does one call the controller via the modal link to mean that the front-end modal dialog has a link, and upon clicking it, they want to trigger their back-end controller to do something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.