On Dec 20, 10:37 am, lordG <[EMAIL PROTECTED]> wrote:
> Hi Guys,
>
> I've got a question, and hopefully one of the cakephp guys can give an
> answer.
>
> First, the scenario...
> I often will used more than one model file to represent the same data.
> A common reason is to separate admin functions from normal ones, so
> the normal model is less intensive to load. There may be other reasons
> like two different data sources, but the same data model.
>
> Now although this does not seem a problem at first, it becomes a
> problem when you start creating forms to represent and manage that
> data. In all these models, the $name variable is set the same (e.g.
> User), so I have transparency between the models (and the models may
> be named: UserModel1, UserModel2 etc). However, when we populate a
> form with the model data using the FormHelper, it requires the
> following name: ModelClass.field (1.2) or ModelClass/field (1.1). Now
> naturally this causes a problem when the models have different class
> names (This may be so that we can store all the models in the same
> directory or even load more than one of them at the same time.)

The above sounds rather over complex to me. What is the benefit of
making several 'models' for one model? (The fact that I ask should
imply that I don't percieve any of the above reasons as a benefit).

> Now my only argument or frustration is why does the FormHelper use the
> Classname as part of the naming of the input field rather than the
> $name variable of the class?

Why is the $name not the same as the class name. That´s begging for
things not to work IMO. 1.2 uses the alias afaik btw, which defaults
to the model name.

> I have no problem in it needing the class
> name to initiate and retrieve the input name value, but I think that
> it would be best that the resulting name was: data[ModelNameVariable]
> [field].
>
> What are your thoughts?
>
> Then, the second part of the conventions is why are controller class
> files named differently to all the other files like models, helpers,
> components etc?

You are refering to plural or _controller? I can´t remember the
specifics but when the _controller was dropped there were naming
conflicts.

> Surely to remain consistent, one should keep the
> naming convention the same all across? My personal preference would be
> that they are all named according to their class name, so much like
> the current controllers are. I understand the impact this would have,
> but I think that this would help keep a stronger convention on the
> naming of the files.

If anything were to change I prefer writing less :).

> A third case to look at is if a component and a model share the same
> $name variable value or Similar class names (Component: User
> "user_component"; Model: User "user"). This causes a problem. To get
> around that I named all my components iClassComponent. However, I
> would think that the best way really to solve this would be to name
> the objects according to their class names, ie: Models would be
> UserModel and Components would be UserComponent. This also allows for
> better usability as you thereby know automatically the type of object
> it is.
>
> What are your thoughts?

Component & Model name conflicts are indeed a problem. Although I
don't think writing "Component" and "Model" after each of them is
necessarily that good an idea. For chained model calls that makes them
quite long, and writing $this-SessionComponent->write(); would
probable get tiring rather quickly.

only IMO of course,

AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to