Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

day 09

  • Loading branch information...
commit ae3f8d7b716886d5bc9fc97e455cb89c1516663c 1 parent b2f7896
@typester authored
View
6 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) {
View
92 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;
+
View
40 root/job/create.mt
@@ -0,0 +1,40 @@
+? my $form = $c->stash->{form};
+
+? extends 'common/jobs_base';
+
+? block content => sub {
+
+<h1>New Job</h1>
+
+<form method="post">
+
+<table id="job_form">
+ <tfoot>
+ <tr>
+ <td colspan="2">
+ <input type="submit" value="Preview your job" />
+ </td>
+ </tr>
+ </tfoot>
+ <tbody>
+? for my $field (qw/category type company url position location description how_to_apply email/) {
+ <tr>
+ <th><?= raw_string $form->label($field) ?></th>
+ <td>
+? if ($form->is_error($field)) {
+ <ul class="error_list">
+? for my $err (@{ $form->error_messages($field) }) {
+ <li><?= raw_string $err ?></li>
+? } # endfor $err
+ </ul>
+? } # endif
+ <?= raw_string $form->input($field) ?>
+ </td>
+ </tr>
+? } # endfor $field
+ </tbody>
+</table>
+</form>
+
+? } # endblock content
+
Please sign in to comment.
Something went wrong with that request. Please try again.