I have this model :
School hasMany Teachers
I have a view action/page on my School controller, where I need to put a "add new teacher for this school" link. This link must lead to the Teacher add page, and the new teacher must reference the school from the previous page.
I am doing this by adding a query string on my link, like :
<a href="/teachers/add?school_id=4">Add new teacher for this school</a>
Then in my TeachersController I pass this value to my view (teacher::add.ctp) as $school_id and create a hidden input in the add.ctp like :
$this->hidden('school_id', ['value' => $school_id])
So when I submit the teacher add form, its school_id field is set correctly.
Is there a better way to do this ? I am not really happy with my solution and the query string trick (one could change this in the address bar...).
Thanks