diff --git a/src/Controller/JobController.php b/src/Controller/JobController.php index d724ce5..dcd767f 100644 --- a/src/Controller/JobController.php +++ b/src/Controller/JobController.php @@ -2,6 +2,7 @@ namespace Dynamic\Jobs\Page; +use Dynamic\Jobs\Form\JobSubmissionForm; use Dynamic\Jobs\Model\JobSubmission; use PageController; use SilverStripe\Control\Controller; @@ -60,14 +61,10 @@ public function apply() } /** - * @return Form + * @return JobSubmissionForm */ - public function JobApp() + public function JobApp(): JobSubmissionForm { - $App = singleton(JobSubmission::class); - - $fields = $App->getFrontEndFields(); - $actions = FieldList::create( new FormAction('doApply', 'Apply') ); @@ -79,9 +76,13 @@ public function JobApp() 'Phone', ]); - $this->extend('updateJobAppForm', $fields, $actions, $required); + $form = JobSubmissionForm::create($this, 'JobApp') + ->setActions($actions) + ->setValidator($required); + + $this->extend('updateJobSubmissionForm', $form); - return Form::create($this, "JobApp", $fields, $actions, $required); + return $form; } /** @@ -116,10 +117,10 @@ public function doApply(array $data, Form $form) $email = new Email($from, $to, $subject, $body); $email ->setHTMLTemplate('Dynamic\Jobs\Email\JobSubmission') - ->setData(new ArrayData(array( + ->setData(new ArrayData([ 'Submission' => JobSubmission::get()->byID($entry->ID), 'Configuration' => $this->parent(), - ))); + ])); $email->send(); diff --git a/src/Form/JobSubmissionForm.php b/src/Form/JobSubmissionForm.php new file mode 100644 index 0000000..e9b1013 --- /dev/null +++ b/src/Form/JobSubmissionForm.php @@ -0,0 +1,59 @@ +setTitle('Resume'); + $ResumeField->getValidator()->setAllowedExtensions([ + 'pdf', + 'doc', + 'docx', + ]); + $ResumeField->setFolderName('Uploads/Resumes'); + $ResumeField->setRelationAutoSetting(false); + $ResumeField->setAttribute('required', true); + + $fields = FieldList::create( + TextField::create('FirstName', 'First Name') + ->setAttribute('required', true), + TextField::create('LastName', 'Last Name') + ->setAttribute('required', true), + EmailField::create('Email') + ->setAttribute('required', true), + TextField::create('Phone') + ->setAttribute('required', true), + DateField::create('Available', 'Date Available'), + $ResumeField, + SimpleHtmlEditorField::create('Content', 'Cover Letter') + ); + + parent::__construct($controller, $name, $fields, $actions, $validator); + } +} diff --git a/src/Forms/SimpleHtmlEditorField.php b/src/Forms/SimpleHtmlEditorField.php index 173d415..8f8e8fa 100644 --- a/src/Forms/SimpleHtmlEditorField.php +++ b/src/Forms/SimpleHtmlEditorField.php @@ -69,7 +69,10 @@ public function setCSS($css) */ public function FieldHolder($attributes = []) { - Requirements::javascript("silverstripe/admin: thirdparty/jquery/jquery.min.js"); + if (!$this->config()->get('disable_jquery_requirement')) { + Requirements::javascript("//code.jquery.com/jquery-1.7.2.min.js"); + } + Requirements::javascript("silverstripe/admin: thirdparty/tinymce/jquery.tinymce.min.js"); Requirements::javascript("silverstripe/admin: thirdparty/tinymce/tinymce.min.js"); Requirements::javascript("dynamic/silverstripe-jobs: javascript/simple_HTML_editor.js"); diff --git a/src/Model/JobSubmission.php b/src/Model/JobSubmission.php index fb1b9b2..4ea4524 100755 --- a/src/Model/JobSubmission.php +++ b/src/Model/JobSubmission.php @@ -136,42 +136,6 @@ public function getTitle() return $this->getName(); } - /** - * @param null $params - * @return FieldList - */ - public function getFrontEndFields($params = null) - { - // Resume Upload - $ResumeField = FileField::create('Resume')->setTitle('Resume'); - $ResumeField->getValidator()->setAllowedExtensions([ - 'pdf', - 'doc', - 'docx', - ]); - $ResumeField->setFolderName('Uploads/Resumes'); - $ResumeField->setRelationAutoSetting(false); - $ResumeField->setAttribute('required', true); - - $fields = FieldList::create( - TextField::create('FirstName', 'First Name') - ->setAttribute('required', true), - TextField::create('LastName', 'Last Name') - ->setAttribute('required', true), - EmailField::create('Email') - ->setAttribute('required', true), - TextField::create('Phone') - ->setAttribute('required', true), - DateField::create('Available', 'Date Available'), - $ResumeField, - SimpleHtmlEditorField::create('Content', 'Cover Letter') - ); - - $this->extend('updateFrontEndFields', $fields); - - return $fields; - } - /** * @return RequiredFields */ @@ -195,12 +159,12 @@ public function getCMSFields() $fields->removeByName([ 'JobID', ]); - + $fields->insertBefore( ReadonlyField::create('JobTitle', $this->fieldLabel('Job.Title'), $this->Job()->getTitle()), 'Content' ); - + $fields->insertBefore( ReadonlyField::create( 'Created', @@ -209,7 +173,7 @@ public function getCMSFields() ), 'Content' ); - + $resume = $fields->dataFieldByName('Resume') ->setFolderName('Uploads/Resumes'); $fields->insertBefore($resume, 'Content'); diff --git a/templates/Dynamic/Jobs/Page/Layout/JobCollection.ss b/templates/Dynamic/Jobs/Page/Layout/JobCollection.ss index beb0142..e454062 100755 --- a/templates/Dynamic/Jobs/Page/Layout/JobCollection.ss +++ b/templates/Dynamic/Jobs/Page/Layout/JobCollection.ss @@ -18,7 +18,7 @@ <% end_loop %> <% with $PaginatedList %> - <% include Pagination %> + <% include Dynamic\Jobs\Includes\Pagination %> <% end_with %> <% else %>

No entries