8vius
8vius

Reputation: 5836

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?

Upvotes: 0

Views: 64

Answers (1)

Matthew Nessworthy
Matthew Nessworthy

Reputation: 1428

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');

Upvotes: 2

Related Questions