Friday, July 2, 2010

Re: How to implement "helper" fields in my model?

Well, I think the validation part would go in a controller, so you
would want to have the beforesave helper call a function in a
controller, this could also call a component, if needed... I haven't
done this myself but I think this is the correct procedure based on my
understanding of cakephp although I'm fairly new myself to using it.


On Jul 2, 3:49 pm, mofahead <davebrowndes...@gmail.com> wrote:
> 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: