Validate from the controller
Hello Folks! Imagine the following situation: I create a validation rule on the controller, for example, like below: $this-Person-validate = array( 'Name' = array( 'rule' = 'notEmpty', 'message' = 'Some error text message here' ) ); In the view i have a form like this: ?php print $form-input('Person.0.Name'); ? ?php print $form-input('Person.1.Name'); ? I don't want to save the data, just validate it. So, i do the following at the controller: $this-Person-set( $this-data ); $this-Person-validates() { // } However, the code above doesn't validates the data when it is a array like: Array( [0] = array( ['Name'] = 'Some Name' ), [1] = array( ['Name'] = 'Some Name' ) ) With $this-ControllerName-validates(), how can i validate a array like happens when using $this-ModelName-saveAll(). Best Regards, Felipe Carballo -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Validate from the controller
I'm not 100% sure I understand what you are going for here, but if all you want to do is validate the input THEN save, which is what I gather from your question (please correct me if I'm wrong) then you need to move your validation code to the model and anything else if you want to do before a save you can put it in a callback. i.e beforeSave in the model as well I hope this helps -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Validate from the controller
I believe you have to use saveAll() in this instance, validates() only supports 1 array dimension. On Feb 14, 9:23 am, Dee Johnson devario...@gmail.com wrote: I'm not 100% sure I understand what you are going for here, but if all you want to do is validate the input THEN save, which is what I gather from your question (please correct me if I'm wrong) then you need to move your validation code to the model and anything else if you want to do before a save you can put it in a callback. i.e beforeSave in the model as well I hope this helps -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Validate from the controller
Miles J, it's all i want to know. If validates() supports only one array dimension, i can't validate like i did. =/ Thank you folks. On Feb 14, 4:19 pm, Miles J mileswjohn...@gmail.com wrote: I believe you have to use saveAll() in this instance, validates() only supports 1 array dimension. On Feb 14, 9:23 am, Dee Johnson devario...@gmail.com wrote: I'm not 100% sure I understand what you are going for here, but if all you want to do is validate the input THEN save, which is what I gather from your question (please correct me if I'm wrong) then you need to move your validation code to the model and anything else if you want to do before a save you can put it in a callback. i.e beforeSave in the model as well I hope this helps -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php