This is my config file which contains form attributes in CodeIgniter.
$config['reg_attribute'] = array(
'form' => array(
'id' => 'reg-form',
'class' => 'form-horizontal',
'role' => 'form'
),
'name' => array(
'id'=>'reg-name',
'class' => 'form-control',
'name'=>'name',
'placeholder' => 'Enter name',
'value'=>set_value('name')
),
'gender' => array(
'id'=>'reg-reg',
'class' => 'form-control',
'name'=>'gender',
'value'=>set_value('gender')
),
'contact_no' => array(
'id'=>'reg-reg',
'class' => 'form-control',
'name'=>'contact_no',
'placeholder' => 'Enter Phone number',
'value'=>set_value('contact_no')
),
'email'=> array(
'id'=>'reg-email',
'class' => 'form-control',
'name'=>'email',
'placeholder' => 'Enter Email',
'value'=>set_value('email')
),
'password' =>array(
'id'=>'reg-password',
'class' => 'form-control',
'name'=>'password',
'placeholder'=>'Enter Password',
'value'=>set_value('password')
),
'confirm_password' =>array(
'id'=>'reg-password',
'class' => 'form-control',
'name'=>'confirm_password',
'placeholder'=>'Enter Confirm Password',
'value'=>set_value('confirm_password')
),
'submit' =>array(
'id' => 'btn-login',
'class' => 'btn btn-success',
'name' => 'submit',
'value' => 'Register'
)
);
Here I'm loading the form attributes from config and storing it into
an array $data["reg_attrib"]
$this->config->load('reg_rules');
$data["reg_attrib"] = $this->config->item("reg_attribute");
I have an another array which is $add_form
$add_form = array(
'action' => base_url('admin/user/insert'),
'title' => 'Add User',
);
Now I want to merge both the array's into a single array
and send it to view i.e to $add_attributes
.
$this->admin_layout->view('admin/add_user',$add_attributes);
Simply merge them with array_merge()
. Try this -
$add_attributes = array_merge($data["reg_attrib"], $add_form);