Welcome Guest, Not a member yet? Register   Sign In
count of empty array
#5

[eluser]PHPraja[/eluser]
Actually i got this count of empty array while validations using call back functions.

In my 'EmailToFriend' view i have a message box(text area), some list of dynamic check boxes(Friends list) and a textarea where the user can enter his friends emailid with a comma separated. Before submitting the form we should validate such that atleast one checkbox is checked or atleast one emailid is entered in the textarea. for this i used a CI validation as below using callback function.

Code:
$rules['emailslist']="callback_emailslist_check";
        $rules['message']="required";
        $this->validation->set_rules($rules);
        $fields['emailslist']    = " Email List ";
        $fields['message']    = " Message ";
        $this->validation->set_fields($fields);
        
        
        if ($this->validation->run() == FALSE)
            {   redirect(place/placeemail); }

// This is a call back function
   function emailslist_check($e)
        {
            if((count($this->input->post('chkEmails'))==1 ) && ($e==''))
            {
                //echo count($this->input->post('chkEmails')); die;
                $this->validation->set_message('emailslist_check', 'At least one recipient is required');
                return FALSE;
            } else {
            return TRUE;
            }
        }

In the above code 'emailslist' is the name of the textarea where the emailids should be entered and 'chkEmails' is the dynamic array (checkbox name ) This call back function does nt work. In the callback function can i check combination of two fields for validation? as i used above. I hope the above explanation is clear to express my doubt. any one plz help..


Messages In This Thread
count of empty array - by El Forum - 05-08-2008, 02:02 AM
count of empty array - by El Forum - 05-08-2008, 02:10 AM
count of empty array - by El Forum - 05-08-2008, 02:28 AM
count of empty array - by El Forum - 05-08-2008, 02:51 AM
count of empty array - by El Forum - 05-08-2008, 04:08 AM
count of empty array - by El Forum - 05-08-2008, 05:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB