I’m working on a custom module and using the form_validation library to validate the input from a form.
Upon error, I the errors are not being displayed. The code I’m using is below… same stuff I use when working with typical CI.
The view:
<?php echo validation_errors(); ?>
<?php echo form_open($action_url); ?>
<label for="group_name">Name of Group <em class="required">*</em></label>
<input name="group_name" id="group_name" class="field" maxlength="255" value="<?php echo set_value('group_name', isset($group) ? $group->name : ''); ?>" >
<?php if(isset($group)): ?>
<input type="hidden" name="group_id" value="<?php echo $group->id; ?>" >
<?php endif; ?>
<input type="submit" class="submit" value="<?php echo !isset($group) ? 'Add' : 'Update'; ?> this group" /> or <a href="http://<?php">Go back</a>
<?php echo form_close(); ?>The mcp file method:
$this->EE->load->library('form_validation');
$rules = array(
array('field' => 'group_name', 'label' => 'mame of group', 'rules' => 'trim|required|max_length[255]|htmlentities'),
);
$this->EE->form_validation->set_rules($rules);
if($this->EE->form_validation->run())
{
$group_params = array(
'name' => $this->EE->input->post('group_name')
);
$this->EE->db->insert('oneliner_groups', $group_params);
$this->EE->session->set_flashdata('message_success', $this->EE->lang->line('group_added'));
$this->EE->functions->redirect($this->base_url);
}
else
{
$this->add_group();
}Any ideas what I’m doing wrong?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.