The last option seems most feasible for me, so I want to implement the following form code after clicking a button:
<?= $this->Form->create($product) ?>
<?php
echo $this->Form->control('song_name');
...
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
I did not find a direct way to run code from a button (even though I thought onclick would work as an HTML attribute?), so I implemented like this in the add.php of song request:
echo $this->Form->postButton(‘add new song’, ‘nested_song_form.php’);
with the former code in nested_song_form. However, clicking the button leads to no execution of this code, but staying on the same page with the error that the song request could not be saved.