Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:45:19+00:00 2026-06-06T01:45:19+00:00

I am using modular MVC with codeigniter. I have a module playlist in which

  • 0

I am using modular MVC with codeigniter. I have a module playlist in which I have a admin controller and I am having a private $rules variable for setting the form validation rules.

I have both create and edit functions in the same file and validating both the forms (add,edit which are also created dynamically from only one file form.php).

$this->load->library('form_validation');
$this->form_validation->set_rules($this->rules);
$this->form_validation->set_error_delimiters(' <p class="error">', '</p>');

These are used in both create and edit functions. some of the fields i dont want to validate in edit mode. Should I need to create different private rules for both of them or is there any better way to handle this in codeigniter since I am new to it. I want to remove validation for FILE tag as user dont need to upload at edit mode.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:45:22+00:00Added an answer on June 6, 2026 at 1:45 am

    Here is an answer from the CI forums (original link).

    You can define the rules for create/edit using some form of heirachy, then;

    <?php
    $this->form_validation->set_group_rules('createModule');
    $this->form_validation->set_group_rules('editModule');
    if($this->form_validation->run() == FALSE) {
       // whatevere you want
    }
    ?>
    

    Or, you could do this;

    <?php
    // This will validate the 'accidentForm' first
    $this->form_validation->set_group_rules('createModule');
    if($this->form_validation->run() == FALSE) {
       // whatevere you want
    }
    // Now we add the 'locationForm' group of rules
    $this->form_validation->set_group_rules('editModule');
    // And now we validate *both* sets of rules (remember that the createModule rules are still
    // there), but it doesn't necessarily matter, since it will simply redo the 'createModule'
    // validation while also doing the 'editModule' validation
    if($this->form_validation->run() == FALSE) {
       // whatevere you want
    }
    ?>
    

    Below is the code for the extended Form_validation class, saved in the application libraries folder as MY_Form_validation.php

    <?php
    class MY_Form_validation extends CI_Form_validation {
    
        /**
         * Set Rules from a Group
         *
         * The default CodeIgniter Form validation class doesn't allow you to
         * explicitely add rules based upon those stored in the config file. This
         * function allows you to do just that.
         *
         * @param string $group
         */
        public function set_group_rules($group = '') {
            // Is there a validation rule for the particular URI being accessed?
            $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group;
    
            if ($uri != '' AND isset($this->_config_rules[$uri])) {
                $this->set_rules($this->_config_rules[$uri]);
                return true;
            }
            return false;
        }
    
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a modular ASP.NET MVC application using areas. In short, I have
I am using Codeigniter 1.7.2 and HMVC (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home). I have these files and they
I'm using HMVC in CodeIgniter https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home How do I setup a controller that would
We have the beginnings of a modular wpf application built using prism. We want
I have setup a fresh install of codeigniter 2x and modular extensions (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home) It
I'm implementing a modular AI testing engine using the MVC pattern in python. So
I am building a modular framework for a PHP MVC site. I am using
I am using a MVC framework which is a bit like struts. So, say
i need to load a library from my module using Modular Extensions my structure
I'm new to codeigniter and building web applications using MVC. I'm trying to wrap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.