Now on Job detail page there is an online apply button which moves you to the Applicant online apply form.
now on that form I want to print the job_id in a hidden text field(which is a forign key in Applicant table), because both Jobs and Applicants are in relation.
I am trying this but it gives me "Trying to get property of non-object" error.
You could create a new action in your job controller and ditch the application controller. You really don’t need it because you shouldn’t allow applications to be changed once submitted. If you have over 50 employees within a 75 mile radius and in the USA you should have it forward to an EEO and VET status page (must be different pages according to our HR lawyers check with yours) that collects their info for those too.
That’s what i did for my job tracking script i wrote awhile back and remove your hidden fields that anyone can change if they view the script.
public function actionApplication($id)
{
$model=$this->loadModel($id);
$applicant=new Applicant;
if(isset($_POST['Applicant']))
{
$applicant->unsetAttributes(); // clear any default values
$applicant->attributes=$_POST['Applicant'];
$valid=$applicant->validate();
if($valid)
{
$applicant->job_id = $id;
if($applicant->save()) {
$this->redirect(array('eeopage','id'=>$applicant->id));//you want to make sure the eeo stays with the applicant so get the next application id
}
}
}
$this->render('application',array(
'model'=>$model,
'applicant'=>$applicant
));
}
You could also add another view file and action in your job to “manage” the submitted ones. I have it so under the admin view of the job you can see applicants for that job. That’s what i did.