Welcome Guest, Not a member yet? Register   Sign In
Validation help please
#1

[eluser]LifeSteala[/eluser]
I have a form, with Textarea (Description), Input (Due Date), Textarea (Internal Owner) and Input (External Owner).

I set the rule and field for description..

I created a callback function for this reason:

If description is filled in, then there MUST be a date and the Internal OR External owner must be set before it goes into the database.

Code is unfinished but i'll post it anyways. I get this error:

Unable to access an error message corresponding to your field name.

Code:
$this->_loadViews($data, $viewQu);
    
$rules['nextactdesc']       = "callback__nextAction";
$this->validation->set_rules($rules);

$fields['nextactdesc']      = "Next Action Description";
$this->validation->set_fields($fields);
        
if ($this->validation->run() == FALSE)
{
    $this->_loadViews($data, $viewQu);
}
else
{
    echo "success";
}    

function _nextAction($nextActionField)
{
if (!empty($nextActionField))
{
if ((empty($_POST['duedate'])))
{
$this->validation->set_message('nextactdesc', 'A date is required.');
return FALSE;
}
else
{
if (empty($_POST['internalowner']) && empty($_POST['externalowner']))
{
$this->validation->set_message('nextactdesc', 'An internal or external owner is required');
return FALSE;
}
}
}    
else
{
return TRUE;
}            
}

Can anyone point out what i'm doing wrong please? Cheers
#2

[eluser]Seppo[/eluser]
You have to set the error message after the rule, not the field

try this

Code:
$this->validation->set_message('_nextAction', 'A date is required.');
#3

[eluser]LifeSteala[/eluser]
OMG You are a genius! I love ya and this forum Big Grin. Thanks for your help.
#4

[eluser]RRosset[/eluser]
Hey Seba, after a lotta time i FINALLY discover what 'after the rule' means. Dang you man! hahahaha long live dude,

Btw, this saturday (24-nov) we plan to celebrate Ale's birthday (Caldarone) join us at Bar Antares, Armenia 1447.

Later

Bob




Theme © iAndrew 2016 - Forum software by © MyBB