-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for
<input type="datetime-local">
, per #4
- Loading branch information
1 parent
2d6a2a8
commit a45428d
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace mindplay\kissform\Fields; | ||
|
||
use mindplay\kissform\InputModel; | ||
|
||
/** | ||
* Date/time field-type for string-based input using HTML5 `<input type="datetime-local">`. | ||
* | ||
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local | ||
*/ | ||
class DateTimeLocalField extends DateTimeField | ||
{ | ||
const HTML5_FORMAT = "Y-m-d\\TH:i"; | ||
|
||
/** | ||
* @param string $name field name | ||
* @param string $timezone timezone name | ||
* @param array $attrs map of HTML attribtues to apply | ||
*/ | ||
public function __construct($name, $timezone, $attrs = []) | ||
{ | ||
$attrs += [ | ||
"type" => "datetime-local", | ||
]; | ||
|
||
parent::__construct($name, $timezone, self::HTML5_FORMAT, $attrs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters