[eluser]alberta[/eluser]
hi,
I am using form validation, but error message is not displayed
this is the code
view file
Code:
<table class="{class}">
<?php echo $this->validation->error_string; ?>
<form name="editplan" action="{site_url}index.php/projects/plan_edited" method="post" >
<tbody>
<th colspan="2">{id} - {definition}</th>
</tr>
<td align="right"> </td>
<td >
<input value="Commit" type="button">
</td>
</tbody>
</form>
</table>
controller file
Code:
function edit_plan($plan_id)
{
$data = tags();
$data['tabs'] = tabs('projects');
// get the list of stages
$data['states']= $this->projects_model->get_nominal_plan($limit, $this->uri->segment(4), $plan_id);
// if i don't set it here too, it gives error of Message: Undefined property: CI_Validation::$commit
$rules['commit'] = "required";
$this->validation->set_rules($rules);
$fields['commit'] = 'Commit';
$this->validation->set_fields($fields);
$this->parser->parse('projects/edit_plan', $data);
}
function plan_edited()
{
$this->load->helper( 'form' );
$this->load->helper( 'url' );
$this->load->library('validation');
$rules['commit'] = "required";
$this->validation->set_rules($rules);
$fields['commit'] = 'Commit';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{
// redirects on form page
$pieces = explode("index.php", $_SERVER['HTTP_REFERER']);
redirect($pieces[1]);
}
}
Note: this is an edit form