oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 81 forks source link

DatePicker widget not showing initial value #138

Open Seykotron opened 4 years ago

Seykotron commented 4 years ago

Hi there, its me again!

DatePicker widget is not showing initial value when using it in Filters or in a Form when the form_invalid is raised...

Im trying a lot of things to solve it but nothing seems to work, any clues?

Thank you!!

Seykotron commented 4 years ago

I Found the solution in templates/windgets/datepicker.html we actually have:

<script>
$(function () {
    $('.datepickerwidget').datepicker({
        autoclose: true
    });
});
</script>

<div class="input-group date">
    <div class="input-group-addon">
        <i class="fa {% if icon %}{{ icon }}{% else %}fa-calendar{% endif %}"></i>
    </div>
    <input type="text" class="{{ class }}" data-date-format="{{ format }}" name="{{ name }}" id="{{ id }}" value="{{ value|date:djformat }}" />
</div>

And now to work its:

<script>
    $(function () {
        $('.datepickerwidget').datepicker({
            autoclose: true
        });
    });
</script>
<div class="input-group date">
    <div class="input-group-addon">
        <i class="fa {% if icon %}{{ icon }}{% else %}fa-calendar{% endif %}"></i>
    </div>
    <input type="text" class="{{ class }}" data-date-format="{{ format }}" name="{{ name }}" id="{{ id }}" value="{{ value }}" />
</div>

And now it works! :)

oscarmlage commented 4 years ago

Hey @Seykotron

Cool! Glad to see that it works, maybe if you could send a PR I could merge it to master, what do you think? ;)

Seykotron commented 4 years ago

Done ;)

I also asked for pull request to implement the icontains into filters fields (CharField, TextField and EmailField), if you remember I told you so time ago but havent time to implement that ;)

Proud to contribute to this great framework ;)