简体   繁体   English

如何在laravel刀片上添加HTML 5类型属性?

[英]How do I add HTML 5 type attribute to laravel blade?

I have this line in blade format 我有刀片格式的这一行

{{ Form::text('date', null, array('class' => 'form-control', 'type' => 'Date', 'placeholder' => 'Date' )) }}

but when the page loads the type attribute does not get resolved to 'date', it goes to 'text'. 但是当页面加载时,type属性不会被解析为'date',而是转到'text'。

How do I get this in blade? 如何在刀片中获得此功能?

<input class="form-control" type="date" placeholder="Date" name="date">

Use Form::input() 使用Form :: input()

Form::input('date', 'date', null, ['class' => 'form-control', 'placeholder' => 'Date']);

Additionally, you can create a Form Macro to "add" methods for HTML5 attributes, such as date , email , time , etc. 此外,您可以创建表单宏来“添加”HTML5属性的方法,例如dateemailtime等。

我不确定你是否尝试将Form::text更改为Form::date

使用Laravel 5.1,我将它用于日期字段。

{!! Form::date('start_date', null, ['class' => 'form-control col-md-7 col-xs-12', 'placeholder' => 'Date']); !!}

There are also a couple composer/packagist packages you can quickly install to use HTML5 elements the same way as text , email , and url (eg: Form::date('myDateField') ) 还有一些composer / packagist包,您可以快速安装以使用与textemailurl相同的方式使用HTML5元素(例如: Form::date('myDateField')

Here's one: https://github.com/smalldogs/html5inputs 这是一个: https//github.com/smalldogs/html5inputs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM