0

I'm using ace-admin template (http://ace.jeka.by/) for my CI3 project. I want to populate a modal form from my view. it's working if i put code of modal on the same view, exemple :

 <a href="#modal-table" role="button" class="green" data-toggle="modal">
            <button class="btn btn-sm btn-default" id="myBtn">
                <i class="ace-icon fa fa-plus align-top"></i>
                    Modal
            </button>
        </a>


        <div id="modal-table" class="modal fade" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header no-padding">
         Results for "Latest Registered Domains
      </div>
      <div class="modal-body no-padding">
        azerty        
      </div>
        <div class="modal-footer no-margin-top">
          <button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
            <i class="ace-icon fa fa-times"></i>
                          Closee
          </button>
        </div>
    </div>
  </div> 
</div>

But if i change href to send it to controller like this :

<a href="<?php echo base_url();?>ctl/add/" role="button" class="green" data-toggle="modal">
            <button class="btn btn-sm btn-success" id="myBtn">
                <i class="ace-icon fa fa-plus align-top"></i>
                    New
            </button>
        </a>

and on controller :

$this->theme_view = 'modal';
        $this->render('parametres/utilisateurs/_new', $data);

the render function :

if (isset($this->theme_view)) {
        $template = 'modal';
    } else {
        $template = 'master_view';
    }

    $name = 'contents';
    $this->load->view('layouts/'.$template, $this->template_data);

And the modal layouts :

<div id="modal-table" class="modal fade" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header no-padding">
         Results for "Latest Registered Domains
      </div>
      <div class="modal-body no-padding">
        <?=$contents;?>          
      </div>
        <div class="modal-footer no-margin-top">
          <button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
            <i class="ace-icon fa fa-times"></i>
                          Closee
          </button>
        </div>
    </div>
  </div> 
</div>

the view appear not like a modal form but in new page. Any idea for this ?

m-mas
  • 17
  • 7
  • You would create a new Controller with a public $template variable Your extended Controller will then inherit the $template variable from the Master Controller. [Refrence](https://stackoverflow.com/a/19980640/2174728) – Musa Butt Feb 19 '19 at 13:52
  • that's exactly what I did with the function render(), if it's a modal form, I open it with the $template modal but the problem is that my form opens in a new page and not in modal – m-mas Feb 19 '19 at 14:52

0 Answers0