Model specified for CakePHP Views
Hey all, have a slight problem here. In CakePHP I have a controller that uses several models. When creating a form in a view, the view will always name my UI elements based on what the first model is when开发者_运维百科 I specify $uses = array('Model')
so for instance if my User model is the first in my array then my UI elements will receive id="User(fieldname)"
and name="data['User'][fieldname]"
Anybody know how I switch the models my views are using so I can name them properly according to the data I am manipulating?
When creating a form use the full dot notation:
echo $this->Form->create('ModelName');
echo $this->Form->text('ModelName.field_name');
echo $this->Form->input('ModelName.field_name');
精彩评论