Saturday, April 2, 2011

Re: Euromark function guaranteeFields($requiredFields, $data = null) {

On Sat, Apr 2, 2011 at 3:10 PM, Krissy Masters
<naked.cake.baker@gmail.com> wrote:
> Reading the bit about making fields required in a form so a user can not
> firebug them out and thought is there a way to manually grab the names of
> the fields in a form being rendered in the controller?
> Form might have 50 fields and you need them all, writing out all of that
> would be trauma. (but writing the names and updating the model in the
> future, spelling....so on)
>
> Security component does something with all the names to makes it hash no?
>
> Anyone have any ideas? Here is a link to his excellent idea incase anyone
> wants to read up on it.
>
> http://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
>
> secion => Protection against missing fields

I think it would be best to use a class var in the model.

$this->Model->set(
$this->data,
null,
$this->Model->required_fields
);

You could even have separate field lists for different actions:

$this->Model->set(
$this->data,
null,
$this->Model->required_fields['edit']
);

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: