如何将 HTML 5 类型属性添加到 Laravel Blade?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20763365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:48:25  来源:igfitidea点击:

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

phphtmlformslaravelblade

提问by philly2013

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'.

但是当页面加载时,类型属性没有解析为“日期”,它会转到“文本”。

How do I get this in blade?

我如何在刀片中得到这个?

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

回答by Aken Roberts

Use Form::input()

使用Form::input()

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

Additionally, you can create a Form Macroto "add" methods for HTML5 attributes, such as date, email, time, etc.

此外,您可以创建一个表单宏“增加”方法HTML5属性,如dateemailtime,等。

回答by Ricbermo

I'm not sure but have you try changing Form::textto Form::date?

我不确定,但您是否尝试更改Form::textForm::date

回答by M.J

With Laravel 5.1, I am using this for date field.

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

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

回答by Dustin Brownell

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'))

还有一对夫妇作曲家/您可以快速安装使用相同的方式HTML5元素packagist包textemail以及url(如:Form::date('myDateField')

Here's one: https://github.com/smalldogs/html5inputs

这是一个:https: //github.com/smalldogs/html5inputs