diff --git a/lib/Jobeet/Controller/Job.pm b/lib/Jobeet/Controller/Job.pm index 5328af5..dc4c1bd 100644 --- a/lib/Jobeet/Controller/Job.pm +++ b/lib/Jobeet/Controller/Job.pm @@ -1,6 +1,8 @@ package Jobeet::Controller::Job; use Ark 'Controller'; +with 'Ark::ActionClass::Form'; + use DateTime; use Jobeet::Models; @@ -14,8 +16,10 @@ sub show :Path :Args(1) { my ($self, $c, $job_id) = @_; } -sub create :Local { +sub create :Local :Form('Jobeet::Form::Job') { my ($self, $c) = @_; + + } sub job :Chained('/') :PathPart :CaptureArgs(1) { diff --git a/lib/Jobeet/Form/Job.pm b/lib/Jobeet/Form/Job.pm new file mode 100644 index 0000000..4be6330 --- /dev/null +++ b/lib/Jobeet/Form/Job.pm @@ -0,0 +1,92 @@ +package Jobeet::Form::Job; +use Ark 'Form'; + +use Jobeet::Models; + +param category => ( + label => 'Category', + type => 'ChoiceField', + choices => [map { $_->slug => $_->name } models('Schema::Category')->all], + constraints => [ + 'NOT_NULL', + ], +); + +param type => ( + label => 'Type', + type => 'ChoiceField', + choices => [ + 'full-time' => 'Full time', + 'part-time' => 'Part time', + 'freelance' => 'Freelance', + ], + constraints => [ + 'NOT_NULL', + ], +); + +param company => ( + label => 'Company', + type => 'TextField', + constraints => [ + 'NOT_NULL', + ], +); + +param url => ( + label => 'URL', + type => 'URLField', +); + +param position => ( + label => 'position', + type => 'TextField', + constraints => [ + 'NOT_NULL', + ], +); + +param location => ( + label => 'Location', + type => 'TextField', + constraints => [ + 'NOT_NULL', + ], +); + +param description => ( + label => 'Description', + type => 'TextField', + widget => 'textarea', + attr => { + cols => 30, + rows => 4, + }, + constraints => [ + 'NOT_NULL', + ], +); + +param how_to_apply => ( + label => 'How to apply?', + type => 'TextField', + widget => 'textarea', + attr => { + cols => 30, + rows => 4, + }, + constraints => [ + 'NOT_NULL', + ], +); + +param email => ( + label => 'Email', + type => 'TextField', + constraints => [ + 'NOT_NULL', + ], +); + +1; + diff --git a/root/job/create.mt b/root/job/create.mt new file mode 100644 index 0000000..a91156c --- /dev/null +++ b/root/job/create.mt @@ -0,0 +1,40 @@ +? my $form = $c->stash->{form}; + +? extends 'common/jobs_base'; + +? block content => sub { + +

New Job

+ +
+ + + + + + + + +? for my $field (qw/category type company url position location description how_to_apply email/) { + + + + +? } # endfor $field + +
+ +
label($field) ?> +? if ($form->is_error($field)) { +
    +? for my $err (@{ $form->error_messages($field) }) { +
  • +? } # endfor $err +
+? } # endif + input($field) ?> +
+
+ +? } # endblock content +