Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

date picker

edited September 2013 in Framework

I would like to use a date picker maybe disabling the direct editing of the field. Is there anything like that in Elefant? Thanks.

Comments

  • I believe you can just include the jQuery date/time picker from the blog app like this:

    $page->add_script ('/apps/blog/js/jquery.timepicker.js');
    

    Then call it via:

    <script>
    $(function () {
        $('#datefield').datetimepicker ({
            timeFormat: 'hh:mm:ss',
            dateFormat: 'yy-mm-dd',
            hourGrid: 4,
            minuteGrid: 10
        });
    });
    </script>
    

    I don't see an option to disable the direct editing, but you can probably do that with the click or focus event handlers on the input field. Here's the page with the options for the jQuery plugin:

    http://trentrichardson.com/examples/timepicker/

    Hope that helps!

  • Great help as always.

    I added the add_script in the handler and it is present in the page then I added the call after the field in the view like below.

    <p>
        {"Ordexpiry"}:
    <input type="date" id="ordexpiry" name="ordexpiry" value="{{ gmdate ('Y-m-d H:i', strtotime($data->ordexpiry)) }}" /> <span class="notice" id="ordexpiry-notice">{"Please enter a ordexpiry."}</span> </p> <script> $(function () { $('#ordexpiry').datetimepicker ({ timeFormat: 'hh:mm', dateFormat: 'yyyy-mm-dd', hourGrid: 4, minuteGrid: 10 }); }); </script>

    I get two javascript errors: TypeError: $.datepicker is undefined $.datepicker._base_selectDate = $.datepicker._selectDate; Row 768 of /apps/blog/js/jquery.timepicker.js and TypeError: $.timepicker is undefined $t.datepicker($.timepicker._newInst($t, o)._defaults); Row 759 of /apps/blog/js/jquery.timepicker.js

    If I call datepicker instead of datetimepicker I get only the first error and the date picker is shown entering the field and hidden exiting. Clicking today date something like 20132013-09-04 is inserted in the field.

    I would like to insert date and time like 2013-09-04 12:07.

    Thanks.

  • Yes it works. Thank you very much.

Sign In or Register to comment.