Search code examples
laravelfirefoxlaravelcollective

How to use form::date in laravel to work on all browsers


I try to work with {{Form::date()}} in laravel which will work just fine in chrome but not in firefox

here is firefox view:

firefox

And this is chrome view chrome

What I want is to view in Firefox browser be like chrome view, and for the reason that I don't understand when I try to save in Firefox i get this error:

error

But in chrome will save my data with no problem.

Here is my blade code to collect data:

{{ Form::label('valid_from', 'Valid From') }}
{{ Form::date('valid_from', null, array('class' => 'form-control')) }}

Solution

  • SOLVED

    OK, here is how I solved it.

    I used Bootstrap 3 Datepicker v4 and changed my input field to something like this:

    <div class="col-md-6">
      {{ Form::label('valid_from', 'Valid From') }}
      <div class="form-group">
        <div class='input-group date' id='datetimepicker1'>
          <input type='text' name="valid_from" id="valid_from" class="form-control" />
          <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
          </span>
        </div>
      </div>
    </div>
    

    Then I added JavaScript:

    <script type="text/javascript">
        $(function () {
            $('#datetimepicker1').datetimepicker({
              viewMode: 'years',
              format: 'YYYY-MM-DD'
            });
        });
    </script>
    

    And instead of writing the date manually, I get it from nice and beautiful drop-box and now I can save my data no matter what browser I use.

    Hope this helps others.