Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public function number($name, $value = null, $options = [])
*/
public function date($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
if ($value instanceof \DateTimeInterface) { //By changing the type check to DateTimeInterface, you ensure that the form field can accept both DateTime and Carbon instances.
$value = $value->format('Y-m-d');
}

Expand Down Expand Up @@ -467,7 +467,7 @@ public function datetime($name, $value = null, $options = [])
*/
public function datetimeLocal($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
if ($value instanceof \DateTimeInterface) {
$value = $value->format('Y-m-d\TH:i');
}

Expand Down Expand Up @@ -517,7 +517,7 @@ public function url($name, $value = null, $options = [])
*/
public function week($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
if ($value instanceof \DateTimeInterface) {
$value = $value->format('Y-\WW');
}

Expand Down Expand Up @@ -1036,7 +1036,7 @@ public function image($url, $name = null, $attributes = [])
*/
public function month($name, $value = null, $options = [])
{
if ($value instanceof DateTime) {
if ($value instanceof \DateTimeInterface) {
$value = $value->format('Y-m');
}

Expand Down