【问题标题】:Laravel4: How to pass Datepicker into a form?Laravel4:如何将 Datepicker 传递到表单中?
【发布时间】:2013-11-23 02:51:49
【问题描述】:

为了正确验证,我必须将我拥有的所有表单字段重写到 Laravel4, 主要原因是我需要在所有字段中添加 Input::old。

到目前为止,它在文本、文本区域和复选框方面做得很好。 但我不知道如何处理日历数据。 它是 Datepicker,一个非常不错的 JQuery 插件:https://github.com/eternicode/bootstrap-datepicker 有两个字段,一个用于到达,另一个用于发送。

这是正常工作的html:

            <div class="input-append date ">
              <p>
                <label><span><i class="icon-calendar"></i></span> Arrival Date</label>
                <input type="text" name="arrival" class="datepicker" data-date-format="dd/mm/yyyy" id="checkin" placeholder="click here"/> 
              </p>
            </div>

            <div class="input-append date"> 
              <p>
                <label><span><i class="icon-calendar"></i></span> Outgoing Date</label>
                <input type="text" name="outgoing" class="datepicker" data-date-format="dd/mm/yyyy" id="checkout" placeholder="click here"/>
              </p>                
            </div> 

我如何在 Laravel4 中编写这个? 如果由于某种原因不可能不是什么大问题,但非常重要的是我可以添加 Input::old('arrival') 和 Input::old('outgoing')。 有人知道我该怎么做吗?

非常感谢!

【问题讨论】:

  • 可以肯定的是,你只需要能够传入类属性对吗?
  • 目标是如果表格有错误,已经填写的字段将保持填写。所以我需要以某种方式将 Input::old('') 添加到这两个 Datepicker 字段。
  • 你是用刀片创建两个输入吗?如果可以,您可以编辑并发布该代码吗?
  • 没有没有。目前这两个字段仅在 html 中。
  • 好吧,如果我了解 Input::old() 的工作原理(从未使用过),我会说添加 value="" 可能有效?

标签: jquery twitter-bootstrap datepicker laravel laravel-4


【解决方案1】:

如果您的输入为:

value="{{ Input::old('inputName') }}"

它应该像我们发现的那样工作!

【讨论】:

  • 刀片式语法为:value="{{ Input::old('inputName') }}"
  • 好点!我有点想整个输入不是刀片,所以我应该使用普通的 PHP!我会更新的!
猜你喜欢
  • 1970-01-01
  • 2012-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-05
相关资源
最近更新 更多