Laravel 4 表单构建器自定义字段宏

编程入门 行业动态 更新时间:2024-10-24 06:31:26
本文介绍了Laravel 4 表单构建器自定义字段宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试创建一个自定义 HTML 5 日期字段以在 laravel 4 框架视图中使用.

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.

我正在使用这个表单来创建和编辑一个名为 Event 的模型.

Im using this form to create and edit a model called Event.

如何填充该字段的值?

推荐答案

这就是我所做的:

在我看来,我添加了以下宏

in my view I added the following macro

<?php Form::macro('datetime', function($value) { return '<input type="datetime" name="my_custom_datetime_field" value="'.$value.'"/>'; }); ... ... // here's how I use the macro and pass a value to it {{ Form::datetime($datetime) }}

更多推荐

Laravel 4 表单构建器自定义字段宏

本文发布于:2023-11-23 18:31:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622463.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   字段   表单   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!