On Sat, Dec 20, 2008 at 8:53 PM, Rob Wilkerson <[email protected]> wrote: > > > On Dec 20, 8:10 pm, Rob Wilkerson <[email protected]> wrote: >> On Dec 20, 7:58 pm, Rob Wilkerson <[email protected]> wrote: >> >> > If I were to simplify this example and simple ask that the login field >> > be required, how would I do that? >> >> Do I really need the 'rule' key _and_ the 'allowEmpty' key? Would it >> suffice to remove the 'rule' key and just retain 'required' and >> 'allowEmpty'? > > And, as a follow up, what do I need to do to get the "required" class > to appear? I set up my Address model with the following complete > validation: > > public $validate = array ( > 'street_address_1' => array ( > 'rule' => 'notEmpty', > 'required' => true, > 'allowEmpty' => false, > 'message' => 'Street address is required' > ), > 'city' => array ( > 'rule' => 'notEmpty', > 'required' => true, > 'allowEmpty' => false, > 'message' => 'City is required' > ), > 'state_id' => array ( > 'rule' => 'notEmpty', > 'required' => true, > 'allowEmpty' => false, > 'message' => 'State is required' > ), > 'zip_code' => array ( > 'rule' => array ( 'postal', null, 'us' ), > 'required' => true, > 'allowEmpty' => false, > 'message' => 'Expected a 5 digit U.S. zip code' > ) > ); > > I see the "required" class when I access /addresses/add, but not when > I'm entering an address through another model. I have a Vendor that > belongsTo an Address. I'm using the form on vendors/add where I've > created a form with fields named Address.city, Address.zip_code, etc. > Am I missing something?
A solution to this is still eluding me, so I'm going to bump once and see if a little more visibility helps. I'm hoping to find out: 1. Do I really need the 'rule' key _and_ the 'allowEmpty' key? Would it suffice to remove the 'rule' key and just retain 'required' and 'allowEmpty'? 2. How do I get the "required" class to appear on div's surrounding a $form->input() that is part of an associated model? Thanks, all. -- Rob Wilkerson http://robwilkerson.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
