Skip to content

Instantly share code, notes, and snippets.

@sminnee
Created June 18, 2015 15:10
Show Gist options
  • Save sminnee/9e5573e78254a5ca10a5 to your computer and use it in GitHub Desktop.
Save sminnee/9e5573e78254a5ca10a5 to your computer and use it in GitHub Desktop.
Job Application Form
<?php
// Add this to top of JobPage_Controller
private static $allowed_actions = array(
'ApplicationForm'
);
// Add this to the bottom of JobPage_Controller
public function ApplicationForm() {
$fields = FieldList::create(
TextField::create('Name', 'Full name'),
EmailField::create('Email', 'Email'),
PhoneNumberField::create('Phone', 'Contact phone number'),
DropdownField::create(
'JobID',
'Which job are you applying for?',
$this->AvailableJobs()->map('ID', 'Title')
)->setEmptyString('(Select)'),
TextareaField::create('Content', 'Enter your experience and skills')
);
$actions = FieldList::create(
FormAction::create('processApplication', 'Apply')
);
$validator = RequiredFields::create(array(
'Name',
'Email',
'Phone',
'JobID',
'Content'
));
$form = Form::create(
$this,
'ApplicationForm',
$fields,
$actions,
$validator
);
return $form;
}
Add this below your job listings:
<h3>Apply for a job</h3>
$ApplicationForm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment