In a model, I have a validation like the following:

var $validate = array(
  'name' => array('notempty'),
  'number' => array(
    'notempty'=>array('rule'=>'notempty', 'message'=>'Number must be
specified'),
    'isUnique'=>array('rule'=>'isUnique', 'message'=>'Number is
already used')
  ));

- and in a view:
  echo $form->create();
  echo $form->input('name');
  echo $form->input('number');

Then "name" gets a CSS class with "required", but "number" does not.

However, if I add "'required'=>true" to "number" it does get the
required class - but it breaks my validation, because in some cases, I
want to update the data without supplying the "number" field.

My solution so far is to add "$form->fieldset['validates'][] =
'number';" after "$form->create();", but I guess there should be a
better way...

I guess there is room for some confusion, because "required" in the
form is not the same as "required" in the model validation!

  Regards

    Jonathan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to