Question

I am going to have a datetime value in my admin module and I was looking for a jquery/javascript way of populating the widget as a datetime.

I have looked at the sfExtraFormPlugin and go the datepicker working, but it seems that there is no datetime widget.

Is there another alternative?

I am using sf1.4

Was it helpful?

Solution

There's the jQuery UI Datepicker - lots of options and a nice presentation, not to mention it's from a well supported library.

http://jqueryui.com/demos/datepicker/

OTHER TIPS

Another interesting widget :

http://www.malot.fr/bootstrap-datetimepicker/demo.php

You can both select date and time values. I don't know how to plug it with symfony 1.4, but here is the integration with symfony 2.0 :

    {% block datetime_widget %}
    {% spaceless %}
        {% if widget == 'single_text' %}
            {# block('form_widget_simple') #}
            {{ form_errors(form) }}
            <input type="hidden" id="{{ id }}" name="{{ name }}" value="{% if value %}{{ value|date('Y-m-d H:i:s') }}{% endif %}" />
            <div class="input-append date datetime-picker" data-date="{% if value %}{{ value|date('Y-m-d H:i:s') }}{% endif %}" data-link-field="{{ id }}">
                <input size="16" type="text" value="{% if value %}{{ value|date('j F Y - H:i') }}{% endif %}" readonly>
                <span class="add-on"><i class="icon-remove"></i></span>
                <span class="add-on"><i class="icon-th"></i></span>
            </div>
        {% else %}
            <div {{ block('widget_container_attributes') }}>
                {{ form_errors(form.date) }}
                {{ form_errors(form.time) }}
                {{ form_widget(form.date) }}
                {{ form_widget(form.time) }}
            </div>
        {% endif %}
    {% endspaceless %}
    {% endblock datetime_widget %}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top