Reputation: 13
I have a link which when clicked passes an argument to my controller to a function like so:
/home/inquire/54
This is my controller:
public function inquire($id) {
$this->form_validation->set_rules('inputName', 'Name', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('client/M_inquire.php');
} else {
$this->email->from('[email protected]', 'System');
$this->email->to('[email protected]');
$this->email->subject('New Client Registration');
$this->email->message(
"Name: " . $this->input->post('inputName') . "<br />" .
"Phone: " . $this->input->post('inputPhone') . "<br />" .
"Email: " . $this->input->post('inputEmail') . "<br />" .
"Nurse profession: " . $this->input->post('inputProfession') . "<br />" .
"Nurse ID: " . $nurseid
);
$this->email->send();
$this->load->view('client/M_inquire_success.php');
}
}
THis is my view:
<?php echo form_open('home/inquire'); ?>
<label>Full Name</label>
<input type="text" name= "inputName" id="inputName">
The problem is the controller expects an argument so when the form opens it crashes. Any idea how I can maintain the first argument I passed and gather some form data and email both?
THanks a lot.
Upvotes: 1
Views: 2092
Reputation: 9330
In your call to form_open
in your view you can append the id
.
So, in your controller you could have something like:
...
if ($this->form_validation->run() == FALSE) {
$data['the_id'] = $id;
$this->load->view('client/M_inquire.php', $data);
} else {
...
and then in the view you have:
<?php echo form_open('home/inquire/' . $the_id); ?>
Upvotes: 1