Welcome Guest, Not a member yet? Register   Sign In
Design problem with MVC
#1

[eluser]grolle[/eluser]
Hi,

I#ve a question about designing my application. I'm using CI and Jquery. Now I've an administration site where I want to use several forms (new/edit user, new/edit organisation ...). The Form are displayed in the view (as Jquery Popup) but how can I hande several forms? With many different dropdowns? Here some code:
Code:
MODEL
    class Organisations extends Model{

        function Organisations(){
            parent::Model();
            $this->load->database();
        }


        function getAll(){
            $query=$this->db->get('organisations')->result_array();
            $result = array();
            foreach($query as $q)
                $result[$q['id']] = $q['name'];
            return $result;
        }
...
Code:
CONTROLLER
class Administration extends Controller {

        var $base;

    function Administration()
    {
        parent::Controller();
                if(!$this->auth->user_logged_in()){
                    redirect('main/', 'refresh');
                }
                $this->base = $this->config->item('base_url');
                $this->load->model('Organisations');
    }

    function index()
    {
                $data_h['base']        = $this->base;
                $data_h['js']          = 'administration';
                $data_h['title']       = $this->config->item('app_name').'Administration';
                $data['header']        = $this->load->view('global/header',$data_h,TRUE);
                $data['base']          = $this->base;
                $data['organisations'] = $this->Organisations->getAll();
                $data['anchors']       = $this->load->view('global/navigation','',TRUE);
                $data['footer']        = $this->load->view('global/footer','',TRUE);
        $this->load->view('administration',$data);
    }  //$_POST['email'],$_POST['password']



        function registerUser()
        {
            if ($this->auth->register_user($_POST['organisation'],
                                           $_POST['lastname'],
                                           $_POST['firstname'],
                                           $_POST['phone'],
                                           $_POST['email'],
                                           $_POST['role']
            )){
                redirect('administration/');
            }
        }
}
Code:
VIEW
<?php echo $header; ?>
<div id="dialog" title="Neuen Benutzer anlegen">
    &lt;?php echo form_open('administration/registerUser',array('id' => 'createUser')); ?&gt;
    <fieldset>
        <label for="organisation">Organisation:</label>
        &lt;?php echo form_dropdown('organisation',$organisations,1); ?&gt;
        <label for="lastname">Name:</label>
        &lt;input type="text" name="lastname" id="lastname" /&gt;
        <label for="firstname">Vorname:</label>
        &lt;input type="text" name="firstname" id="firstname" /&gt;
        <label for="phone">Telefon:</label>
        &lt;input type="text" name="phone" id="phone" value="" /&gt;
        <label for="email">Email:</label>
        &lt;input type="text" name="email" id="email" value="" /&gt;
        <label for="role">Rechte:</label>
        &lt;input type="text" name="role" id="role" value="0" /&gt;
    </fieldset>
    &lt;/form&gt;
</div>

    <div id="content">
....
Best regards ....
#2

[eluser]n0xie[/eluser]
What exactly is the question?
#3

[eluser]grolle[/eluser]
Where did I generate my forms(above only one is used!!)?




Theme © iAndrew 2016 - Forum software by © MyBB