Issue
I wanna validate multiple fields at one place. So in a form I have included 4 fields as follows
- facebook_link
- twitter_link
- google_plus_link
- linked_in_link
The user atleast type any one field of above. Please help me to get the solution like, the user types anyone of the links in the form.
Solution
you may add your own Validation Methods.
public $validate = array(
'facebook_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'twitter_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'google_plus_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
'linked_in_link' => array(
'rule' => array('validateLink'),
'message' => '...'
),
);
public function validateLink($link) {
$allFieldsAreEmpty = (
empty($this->data[$this->alias]['facebook_link']) &&
empty($this->data[$this->alias]['twitter_link']) &&
empty($this->data[$this->alias]['google_plus_link']) &&
empty($this->data[$this->alias]['linked_in_link'])
);
return !$allFieldsAreEmpty;
}
Answered By - Pitsanu Swangpheaw Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.