简体   繁体   中英

How to add a time picker to grocery crud

I have two types of date time fields in my database. DATE and TIME. With the DATE field Grocerycrud gives you a date picker when adding a record. With the TIME field Grocerycrud only gives you a text field.

Is there any way to get Grocerycrud to show a time picker for TIME fields?

Use a datetime field instead and you'll get the datepicker and timepicker altogether.

If you wish to use only time fields you'll have to modify GC. This is not the correct way to extend GC but as development seems stopped I guess its ok.

Follow the instrucction from this post: http://www.grocerycrud.com/forums/topic/1573-timepicker-implementation/#entry11462

After a long search and following through the above documentation which didn't work for me I devised my own solution. Convert the type of input field to time using jquery. It was sufficient for me although its not a robust method. It may help in certain situations at least

<script type="text/javascript">

$( document ).ready(function() {
      var a = document.getElementById("field-ScheduledTime");
    a.type="time";                      
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM