On my controller I have a error on this line 'edit' => site_url('admin/users_group_controller_update') .'/'. $this->getId($controller)
When I refresh my page it throws the error Array to string conversion
A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: user/users_group_update.php Line Number: 47
Not sure what to do on that because I need to add variable $controller in to $this->getId($controller);
What changes is best suited to make this work.
<?php
class Users_group_update extends Admin_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin/user/model_user_group');
}
public function index() {
$data['title'] = "Users Group Update";
$controller_files = $this->getInstalled($this->uri->segment(3));
$data['controller_files'] = array();
$files = glob(FCPATH . 'application/modules/admin/controllers/*/*.php');
if ($files) {
foreach ($files as $file) {
$controller = basename(strtolower($file), '.php');
$do_not_list = array(
'customer_total',
'dashboard',
'footer',
'header',
'login',
'logout',
'menu',
'online',
'permission',
'register',
'user_total'
);
if (!in_array($controller, $do_not_list)) {
$data['controller_files'][] = array(
'name' => $controller,
'installed' => in_array($controller, $controller_files),
'edit' => site_url('admin/users_group_controller_update') .'/'. $this->getId($controller)
);
}
}
}
$this->load->view('template/user/users_group_form_update', $data);
}
public function getInstalled($name) {
$controller_data = array();
$this->db->select();
$this->db->from($this->db->dbprefix . 'user_group');
$this->db->where('name', $name);
$query = $this->db->get();
foreach ($query->result_array() as $result) {
$controller_data[] = $result['controller'];
}
return $controller_data;
}
public function getId($controller) {
$this->db->select();
$this->db->from($this->db->dbprefix . 'user_group');
$this->db->where('name', $this->uri->segment(3));
$this->db->where('controller', $controller);
$query = $this->db->get();
return $query->row('user_group_id');
}
}
View
<?php echo Modules::run('admin/common/header/index');?>
<div id="wrapper">
<?php echo Modules::run('admin/common/menu/index');?>
<div id="page-wrapper" >
<div id="page-inner">
<?php
$data = array(
'class' =>
'form-horizontal',
'id' =>
'form-users-group'
);
echo form_open_multipart('admin/users_group_update' .'/'. $this->uri->segment(3), $data);?>
<div class="panel panel-default">
<div class="panel-heading clearfix">
<div class="pull-left" style="padding-top: 7.5px"><h1 class="panel-title"><?php echo $title;?></h1></div>
<div class="pull-right">
<a href="<?php echo base_url('admin/users_group');?>" class="btn btn-primary">Cancel</a>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
<div class="panel-body">
<?php echo validation_errors('<div class="alert alert-warning text-center">', '</div>'); ?>
<div class="form-group">
<?php
$data = array(
'class' => 'col-sm-2'
);
echo form_label('User Group Name', 'name', $data)
;?>
<div class="col-sm-10">
<?php
$data = array(
'id' => 'name',
'name' => 'name',
'class' => 'form-control',
'value' => set_value('name')
);
echo form_input($data)
;?>
</div>
</div>
<table class="table table-striped table-bordered">
<thead>
<tr>
<td>Controller Name</td>
<td>Access</td>
<td>Modify</td>
</tr>
</thead>
<tbody>
<?php if ($controller_files) { ?>
<?php foreach ($controller_files as $controllers) { ?>
<tr>
<td>
<div class="clearfix">
<div class="pull-left">
<?php echo $controllers['name']; ?>
</div>
<div class="pull-right">
<?php if ($controllers['installed']) { ?>
<span class="label label-success">Installed</span>
<span class="label label-danger"><a style="color: #FFF; text-decoration: none;" href="<?php echo $controllers['edit'];?>">Edit Individual Controller</a></span>
<?php } else { ?>
<span class="label label-primary">Not Installed</span>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
<div class="panel-footer">
</div>
</div><!-- Panel End -->
<?php echo form_close();?>
</div><!-- # Page Inner End -->
</div><!-- # Page End -->
</div><!-- # Wrapper End -->
<?php echo Modules::run('admin/common/footer/index');?>