Laravel在发布时形成空白日期

时间:2016-09-15 20:48:50

标签: javascript php jquery laravel datepicker

我有以下观点:

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"
    rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.min.css" />

<form class="form-horizontal" role="form" method="POST" action="{{ route('admin.create_athlete') }}">

{{ csrf_field() }}
<div class="form-group">
    <div class="col-md-6">
        <div class="input-group date" data-provide="datepicker" data-date="2001/01/01">
            <input type="text" readonly="" class="form-control">
            <div class="input-group-addon">
                <span class="glyphicon glyphicon-th"></span>
            </div>
        </div>  
    </div>
</div> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>              
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>    

 <!-- Datepicker -->
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>

      <script type="text/javascript">
        $.fn.datepicker.defaults.format = "yyyy/mm/dd";  
        $('#datepicker').datepicker()
           .on('changeDate', function (ev) {
           $('.datepicker').hide();
        });

        var datepicker = $.fn.datepicker.noConflict(); // return $.fn.datepicker to previously assigned value
        $.fn.bootstrapDP = datepicker;                 
      </script>

在我的控制器中,我返回查看数据的请求:

public function store(Request $request)
{
    return $request->all();
}

日期字段甚至没有列出:{"_token":"3Klr9x8iNW8GUDtCyX4mZFly3U1WPVIZB63Jwev1","name":"f","surname":"f","gender":"male","cellphone":"5","email":"","idnumber":""}

为什么没有使用post命令提交日期值?

1 个答案:

答案 0 :(得分:1)

尝试改变这一点:

<input type="text" readonly="" class="form-control">

到此:

<input name="date" type="text" readonly="" class="form-control">

并检查它是否有效......

Controller通过&#34; name&#34;找到字段。属性。如果你没有提出一个&#34;名称&#34;输入中的字段,不会在post方法中考虑。