We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Form validation errors not displaying upon error (EE2)

Development and Programming

mrtopher's avatar
mrtopher
42 posts
16 years ago
mrtopher's avatar mrtopher

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?

       
mrtopher's avatar
mrtopher
42 posts
16 years ago
mrtopher's avatar mrtopher

No ideas?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.