Change the date the bootstrap-material-datetimepicker calendar returns me

1

Hi, I'm working with the framwork symfony3 and I'm having problems with a date type field that I use datepicker for when I select the date in the calendar, what I get is a string and I really need it to be date type and because of this It gives me an error that the field is not valid. I use the bootstrap-material-datetimepicker and moment libraries for the calendar Form

  - ->add('fechainicio', 'Symfony\Component\Form\Extension\Core\Type\DateType', array(
            'format'=>'yyyy-MM-dd',
            'widget'=>'single_text'))

Twig template view

 <div class="col-lg-4 col-md-3 col-sm-3 col-xs-6">
                            <div class="form-group form-float">
                                <div  class="form-line "  >
                                    {{ form_widget(form.fechainicio,{'attr':{'class': 'datepicker form-control','placeholder':'Fecha Inicio del Proyecto'}})}}
                                    {{ form_errors(form.fechainicio) }}
                                </div>

                            </div>
                        </div>
    
asked by Barbara Ross Veitia 26.04.2018 в 20:29
source

1 answer

0

When invoking the datepicker script you can pass as an option the format in which you want to return the date. In your case something like:

{% block js %}
   {{ parent() }}
    <script>
        $('.datepicker').datepicker({
            format: 'dd/mm/yyyy',
        });
    </script>
{% endblock %}
    
answered by 11.12.2018 в 17:52