Welcome Guest, Not a member yet? Register   Sign In
[Solved] Select Form Question
#1

(This post was last modified: 03-24-2015, 11:37 PM by wolfgang1983.)

On my user form I can select a list of permission groups available.

On my user table there is a column where called permission_group and that has permission group user is in.

The select form on my view can only currently show what permission names are available.

I would like to know how on the select form that can show that users permission_group first. $data['permission'] = $user_info['permission_group'];


PHP Code:
public function edit() {
$data['title'] = "Users";

$data['entry_username'] = "Username";
$data['entry_group'] = "User Group";
$data['entry_email'] = "Email";
$data['entry_img'] = "User Image";
$data['entry_password'] = "Passowrd";
$data['entry_confirm_password'] = "Confirm Passowrd";
$data['entry_status'] = "User Status";

$user_info $this->model_user->get_single_user_info();

$data['username'] = $user_info['username'];

// Gets permission name from user table
$data['permission'] = $user_info['permission_group']; 

// Gets current list of permission names from permission_names table.
$data['permission_names'] = $this->model_user->get_permission_group_names(); 

$data['email'] = $user_info['email'];

$data['status'] = $user_info['status'];

$this->form_validation->set_rules('username''Username''required|callback_hasPermission');
$this->form_validation->set_rules('permission_group''Permission Group');
$this->form_validation->set_rules('password''Password''matches[confirm_password]');
$this->form_validation->set_rules('email''Email''required|is_valid');
$this->form_validation->set_rules('confirm_password''Confirm Password''matches[password]');
$this->form_validation->set_rules('status''Status''required');

if (
$this->form_validation->run($this) == FALSE) {

$this->load->view('template/user/user_update_view'$data);
} else {

redirect('admin/users');

}


View



Quote:<div class="form-group">

        <label class="col-sm-2" for="input-group"><?php echo $entry_group; ?></label>
        <div class="col-sm-10">
        <select name="permission_group" class="form-control">
            <?php foreach ($permission_names as $p_name) { ?> <!-- Shows current permission_names available only -->
                <option value="<?php echo $p_name['group'];?>"><?php echo $p_name['group'];?></option>
            <?php }?>           
        </select>
        </div>
    </div>
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Select Form Question - by wolfgang1983 - 03-24-2015, 06:44 AM
RE: Select Form Question - by CroNiX - 03-24-2015, 07:51 AM
RE: Select Form Question - by wolfgang1983 - 03-24-2015, 08:50 AM
RE: Select Form Question - by CroNiX - 03-24-2015, 09:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB