Welcome Guest, Not a member yet? Register   Sign In
Form_validation unset 'set_rules'
#1

[eluser]Walle[/eluser]
Hello,

I have a view with two blocks. A and B. Both are used to write/change data on the database. Both blocks are in one <form> tag on the view. Now the thing I wan't to achieve is, that when I press the submit button, block B will be checked with some validation rules, and if they all succeed, block B should be comitted to the database.

After block B gets validated, block A should be validated and committed to the database as well. That is not hard to achieve.

But if B fails, I still want to validate A to be committed to the database, and they have to be in that order. First B, then A. You might say that A always has to be validated.

I have not really an idea how to achieve that. I wrote something like this in my controller:

Code:
// block B
$this->form_validation->set_rules('description', 'Description', 'required');
if ($this->form_validation->run() == TRUE) {
    // execute code for block B

    // validation for block A
    $this->form_validation->set_rules('responsible_user', 'Responsible_user', '');
    if ($this->form_validation->run() == TRUE) {
        // execute code for block A
    }
} else {
// block A
    ???
    $this->form_validation->set_rules('responsible_user', 'Responsible_user', '');
}

I have to remove the first rule I specified in block B where I put the question marks in the else clause. But I don't have an idea how to do that.

Anyone has any ideas?

It would really help me out.

Kind regards,

Walle


Messages In This Thread
Form_validation unset 'set_rules' - by El Forum - 10-21-2014, 01:23 AM
Form_validation unset 'set_rules' - by El Forum - 10-21-2014, 05:29 AM
Form_validation unset 'set_rules' - by El Forum - 10-21-2014, 10:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB