Skip to content

Commit

Permalink
Merge pull request #108 from martinbean/feature/datetime-inputs
Browse files Browse the repository at this point in the history
Add datetime input types
  • Loading branch information
adamgoose committed Nov 6, 2015
2 parents a4acc4a + cea1f61 commit 5ad8377
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,42 @@ public function date($name, $value = null, $options = [])
return $this->input('date', $name, $value, $options);
}

/**
* Create a datetime input field.
*
* @param string $name
* @param string $value
* @param array $options
*
* @return string
*/
public function datetime($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
$value = $value->format(DateTime::RFC3339);
}

return $this->input('datetime', $name, $value, $options);
}

/**
* Create a datetime-local input field.
*
* @param string $name
* @param string $value
* @param array $options
*
* @return string
*/
public function datetimeLocal($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
$value = $value->format('Y-m-d\TH:i');
}

return $this->input('datetime-local', $name, $value, $options);
}

/**
* Create a time input field.
*
Expand Down

0 comments on commit 5ad8377

Please sign in to comment.