Skip to content

Commit

Permalink
day 09
Browse files Browse the repository at this point in the history
  • Loading branch information
typester committed Dec 9, 2009
1 parent b2f7896 commit ae3f8d7
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 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;

Expand All @@ -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) {
Expand Down
92 changes: 92 additions & 0 deletions 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;

40 changes: 40 additions & 0 deletions 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

0 comments on commit ae3f8d7

Please sign in to comment.