$this->Form->create($article); // Article controls. echo $this->Form->control('title'); // Author controls (belongsTo) echo $this->Form->control('author.id'); echo $this->Form->control('author.first_name'); echo $this->Form->control('author.last_name'); // Author profile (belongsTo + hasOne) echo $this->Form->control('author.profile.id'); echo $this->Form->control('author.profile.username'); // Tags controls (belongsToMany) // as separate inputs echo $this->Form->control('tags.0.id'); echo $this->Form->control('tags.0.name'); echo $this->Form->control('tags.1.id'); echo $this->Form->control('tags.1.name'); // Inputs for the joint table (articles_tags) echo $this->Form->control('tags.0._joinData.starred'); echo $this->Form->control('tags.1._joinData.starred'); // Comments controls (hasMany) echo $this->Form->control('comments.0.id'); echo $this->Form->control('comments.0.comment'); echo $this->Form->control('comments.1.id'); echo $this->Form->control('comments.1.comment'); $this->Form->end();
$article = $this->Articles->patchEntity($article, $this->request->getData(), [ 'associated' => [ 'Authors', 'Authors.Profiles', 'Tags', 'Comments', ], ]);
// Multiple select element for belongsToMany // Does not support _joinData echo $this->Form->control('tags._ids', [ 'type' => 'select', 'multiple' => true, 'options' => $tags, // $tags is the output of $this->Articles->Tags->find('list')->all() in the controller ]);