Im trying to create a custom HTML 5 date field for using in a laravel 4 framework view.
{{
Form::macro('datetime', function($field_name)
{
return '';
});
}}
{{ Form::label('event_start', 'Event Date', array('class' => 'control-label')) }}
{{ Form::datetime('event_start') }}
The only problem is the value is not being populated, and i do not know how to do this.
Im using this form to create and edit a model called Event.
how can i populate the value of this field?
I added in app/start/global.php the following:
But the "good way" would be to extend the Form class and implement your methods.
I've found another way to do this which is putting my macros in a file named
macros.php
then place it underapp/
directory along withfilters.php
androuts.php
, then in theapp/start/global.php
I added the following line at the endthis will load your macros after the app has started and before the view is constructed. it seamed neater and following the Laravel's convention because this is the same way Laravel uses to load the
filters.php
file.Using a macro is not necessary. Just use Laravel's built-in
Form::input
method definingdate
as your desired input type:This appears not to be in the main docs but is in the API docs as linked above.
this works for me:
instead of doing
you can use
Here's what I did:
in my view I added the following macro