ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker Date Field

March 21, 2011 1:00pm

Subscribe [9]
  • #16 / Apr 06, 2011 1:18pm

    apsbb

    3 posts

    Hi Sue,
    Well I might do just that, but it’s weird. From a technical standpoint this may be expected behavior, but to our client it sure isn’t….

  • #17 / Apr 06, 2011 1:53pm

    Sue Crocker

    26054 posts

    Which is why when you fill out your feature request, post it from the perspective of the client. The Dev team looks at feature requests and creates user stories to explain the new feature. If you already have the request in that format, it saves a step.

    Does that help?

  • #18 / Apr 12, 2011 8:27am

    Pv Ledoux

    95 posts

    Hi Sue,

    sorry for my late response. My opinion is that you should give the developer the choice to show the current date to required field or not. So the conditional is not a so bad thing, but the fact that we have 1970-01-01 in non-required-empty-date-field is really annoying.

    Best regards,


    Pv

  • #19 / Apr 12, 2011 8:08pm

    Brandon Jones

    5500 posts

    We appreciate the feedback, Pv. Please do take a moment to file a feature request as SafeCracker is being integrated into ExpressionEngine, and we are looking at ways to improve it further during this process.

  • #20 / Aug 17, 2011 6:23pm

    Wes Baker

    343 posts

    Sanity11,

    Would you mind trying this fix to see if it fixes your problems? Take a look at system/expressionengine/modules/safecracker/libraries/safecracker_lib.php for this line (around line 998 for the version of SafeCracker included in 2.2.2, line 913 in the version that was up for download around the time of 2.1.3):

    $this->head .= '<script type="text/javascript">$.createDatepickerTime=function(){a=new Date();b=a.getHours();c=a.getMinutes();if(c<10){c="0"+c;}if(b>12){b-=12;d=" PM";}else if(b==12){d=" PM";}else{d=" AM";}EE.date_obj_time=" \\'"+b+":"+c+d+"\'";};$.createDatepickerTime();</script>';

    Replace that line with these lines:

    $this->head .= '
    <script type="text/javascript">
        $.createDatepickerTime=function(){
            date = new Date();
            hours = date.getHours();
            minutes = date.getMinutes();
            suffix = "";
            format = "' . $this->EE->config->item('time_format') . '";
        
            if (minutes < 10) {
                minutes = "0" + minutes;
            }
        
            if (format == "us") {
                if (hours > 12) {
                    hours -= 12;
                    suffix = " PM";
                } else if (hours == 12) {
                    suffix = " PM";
                } else {
                    suffix = " AM";
                }
            }
        
            return " \'" + hours + ":" + minutes + suffix + "\'";
        }
    
        EE.date_obj_time = $.createDatepickerTime();
    </script>';

    Let me know if that works for you.

    Wes

  • #21 / Sep 01, 2011 7:06am

    Benjamin

    116 posts

    Hi Wes,

    Found this thread while looking for almost the same problem, but your fix works for me on 2.2.2.
    Thanks.

  • #22 / Sep 01, 2011 11:17pm

    Dan Decker

    7338 posts

    Benjamin,

    Thanks for reporting back! Glad to know Wes’s code got you all fixed up. Let us know if you have any further questions.

    @all,

    Has anyone else had a chance to apply the patch Wes provided above? If so, do you have any feedback to offer?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases