Skip to content

Commit

Permalink
fix datetime_field helper to use the correct type attribute value
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 18, 2016
1 parent 1650388 commit 0b4da08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

6.47 2016-02-15
6.47 2016-02-18
- Fixed datetime_field helper to use the correct type attribute value.

6.46 2016-02-13
- Improved Mojo::Headers performance. (batman)
Expand Down
15 changes: 8 additions & 7 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -9,10 +9,11 @@ sub register {
my ($self, $app) = @_;

# Text field variations
my @time = qw(date datetime month time week);
my @time = qw(date month time week);
for my $name (@time, qw(color email number range search tel text url)) {
$app->helper("${name}_field" => sub { _input(@_, type => $name) });
}
$app->helper(datetime_field => sub { _input(@_, type => 'datetime-local') });

my @helpers = (
qw(csrf_field form_for hidden_field javascript label_for link_to),
Expand Down Expand Up @@ -302,15 +303,15 @@ get picked up and shown as default.
=head2 datetime_field
%= datetime_field 'end'
%= datetime_field end => '2012-12-21T23:59:59Z'
%= datetime_field end => '2012-12-21T23:59:59Z', id => 'foo'
%= datetime_field end => '2012-12-21T23:59:59'
%= datetime_field end => '2012-12-21T23:59:59', id => 'foo'
Generate C<input> tag of type C<datetime>. Previous input values will
Generate C<input> tag of type C<datetime-local>. Previous input values will
automatically get picked up and shown as default.
<input name="end" type="datetime">
<input name="end" type="datetime" value="2012-12-21T23:59:59Z">
<input id="foo" name="end" type="datetime" value="2012-12-21T23:59:59Z">
<input name="end" type="datetime-local">
<input name="end" type="datetime-local" value="2012-12-21T23:59:59">
<input id="foo" name="end" type="datetime-local" value="2012-12-21T23:59:59">
=head2 email_field
Expand Down
8 changes: 4 additions & 4 deletions t/mojolicious/tag_helper_lite_app.t
Expand Up @@ -160,7 +160,7 @@ $t->post_ok('/text')->status_is(200)->content_is(<<'EOF');
<form action="/text" method="POST">
<input class="foo" name="color" type="color" value="#ffffff">
<input class="foo" name="date" type="date" value="2012-12-12">
<input class="foo" name="dt" type="datetime" value="2012-12-12T23:59:59Z">
<input class="foo" name="d" type="datetime-local" value="2012-12-12T23:59:59">
<input class="foo" name="email" type="email" value="nospam@example.com">
<input class="foo" name="month" type="month" value="2012-12">
<input class="foo" name="number" type="number" value="23">
Expand All @@ -179,7 +179,7 @@ $t->post_ok(
'/text' => form => {
color => '#000000',
date => '2012-12-13',
dt => '2012-12-13T23:59:59Z',
d => '2012-12-13T23:59:59',
email => 'spam@example.com',
month => '2012-11',
number => 25,
Expand All @@ -194,7 +194,7 @@ $t->post_ok(
<form action="/text" method="POST">
<input class="foo" name="color" type="color" value="#000000">
<input class="foo" name="date" type="date" value="2012-12-13">
<input class="foo" name="dt" type="datetime" value="2012-12-13T23:59:59Z">
<input class="foo" name="d" type="datetime-local" value="2012-12-13T23:59:59">
<input class="foo" name="email" type="email" value="spam@example.com">
<input class="foo" name="month" type="month" value="2012-11">
<input class="foo" name="number" type="number" value="25">
Expand Down Expand Up @@ -573,7 +573,7 @@ __DATA__
%= form_for text => begin
%= color_field color => '#ffffff', class => 'foo'
%= date_field date => '2012-12-12', class => 'foo'
%= datetime_field dt => '2012-12-12T23:59:59Z', class => 'foo'
%= datetime_field d => '2012-12-12T23:59:59', class => 'foo'
%= email_field email => 'nospam@example.com', class => 'foo'
%= month_field month => '2012-12', class => 'foo'
%= number_field number => 23, class => 'foo'
Expand Down

0 comments on commit 0b4da08

Please sign in to comment.