Friday, July 2, 2010

How to implement "helper" fields in my model?

Hi all,

I'm fairly new to cakephp so forgive me if this question has an
obvious answer. It seems like it must be a common problem but I can't
seem to find any documentation for it.

The gist of it is that I have a product model, and the product has
length and width fields (number of inches, stored as integers). I
would like to let users input length and width as ft and inches.
Essentially feet would be a sort of "helper" field, which before
saving would simply be converted and added to the "real" length and
width values.

Of course I could add an input field in the view and process it in the
model with a beforeSave filter. But what about validation?

Is there an elegant solution for this sort of simple problem?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en

No comments: