I think i’ve missed something. (cakephp)
I have a hasMany relationship from applicants to employers.And when i view an applicant, i see the related employers table all working perfectly (thanks to bake!)
But if i click ‘New Employer’, i want the applicants dropdown to pre-select so that i can hide it. i just cant figure out how i’d pass the applicant_id to the add view for employers.
(if i edit an employer from the related employers table for an applicant, the applicant_id does get passed)
Can anyone help? please?
Vauneen
Simple. Pass the
applicant_idto youremployers/addaction.One way to do this is through URL parameters. Example:
/employers/add/3will pass “3” to the add action, and this could be taken as the applicant ID. Here’s the controller code:Now, you need to ensure that all links provide the applicant ID parameter:
(Note: The last element “3” is the applicant ID)
Finally, you can hide the applicant ID from the form in the
add.ctpfile:Hope that helps!