Use... $this->data[$this->name]['fieldname']
function checkEmpty($value) { $valid = false; if ($value == 'c' && !empty($this->data[$this->name]['field4']) { $valid = true; } elseif (($value == 'a' || $value == 'b') && !empty($this->data[$this->name]['field2']) && empty($this->data[$this->name]['field3'])) { $valid = true; } return $valid; } I often use pr($this) in my model to figure out how certain things work. Cheers, Adam On Dec 16, 8:08 am, stefuNz <[EMAIL PROTECTED]> wrote: > hi chris! > > i think i found what you meant ... "custom validation methods", right? > > but i have one little problem. i don't know how to access field2, > field3, field4 when validating field1... > here's my approach: > > var $validate = array( > 'field1' => array( > 'rule' => array('checkEmpty'), > 'message' => 'Required field empty.' > ) > ); > function checkEmpty($data) { > $valid = false; > print_r($data); > if($data == "c" AND !empty($field4)) $valid = true; > elseif(($data == "a" OR $data == "b") AND !empty($field2) AND ! > empty($field3)) $valid = true; > return $valid; > } > > you see ... i don't know how to access field2 - field4 > do you know how i can handle that situation? > sorry im just new to cakephpp > > sincerely > stefan > > On 15 Dez., 20:36, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > > > On Dec 15, 2007 2:34 PM, stefuNz <[EMAIL PROTECTED]> wrote: > > > > Hi! > > > > I want to use validation for the following situation: > > > > I have a select field (field1) with options a,b,c > > > If field1 is a or b then field2 and field3 may not be empty (text > > > fields) > > > if field1 is c then field4 may not be empty ... > > > > is there a way to use the validation for this or has it to be > > > "manually" > > > Sounds to me like it is definitely custom validation, which means > > you'll have to do it "manually". Luckily it's very easy to do it. > > >http://tempdocs.cakephp.org/#TOC121877 > > > Hope that helps. > > > -- > > Chris Hartjes > > > My motto for 2007: "Just build it, damnit!" > > > @ TheKeyboard -http://www.littlehart.net/atthekeyboard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---