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]
  • #1 / Mar 21, 2011 1:00pm

    Sanity11

    314 posts

    Hi There.

    I am experiencing a problem (Bug?) with the safecracker date field.

    In my localization settings I have set the time format to be European. When opening the date field this is correct. But after changing the date the format become’s incorrect. I have made some images to show the problem:

    1: Editing the page, and the date field show’s up with a correctly formatted time:
    correct.png

    2: Changing the date:
    changing.png

    3: After changing:
    wrong.png

    When I just select the time including the PM and retype the time to the currect time it works, but the resulting time is not correct since it adds one hour to the time I have entered. I have tried changing the daylight saving time settings and the timezone, but this does not solve the problem.

    1: Changing the time like this:
    input.png

    2: Results in:
    result.png

    This functionality is imperative for this website, so I would really appreciate someone helping me solve this problem 😊.

    EDIT: The last problem, with the hour added is solved by applying the solution that is found here: https://support.ellislab.com/bugs/detail/15202/
    The AM/PM problem is still there.

    Thanks!

  • #2 / Mar 22, 2011 5:40am

    John Henry Donovan

    12339 posts

    Sanity11,

    What version and build of EE and SC are you using?

    It is essential you have the latest so we can try and replicate this.

    Can you also share your SC template tags please?

  • #3 / Mar 22, 2011 5:53am

    apsbb

    3 posts

    Hi John,

    EE v2.1.3
    SC v2.0

    This is the code:

    {if segment_4 != "" AND logged_in}
                            
                            {exp:safecracker channel="voorstellingen" return="{segment_1}/{segment_2}/{segment_3}" entry_id="{segment_4}" include_jquery="no"}
                            <div class="content_left_sub">
                                <h1>Bewerk voorstelling:</h1>
                            </div><!-- .content_left_sub -->
                            <div class="safecracker">
                            
                            <table width="100%" class="edit_table">
                                <tr>
                                    <td>
                                        <label for="title">Titel</label>
                                    </td>
                                    <td>
                                        <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="url_title">URL Titel</label>
                                    </td>
                                    <td>
                                        <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    {status_menu}
                                        <label for="status">Status</label>
                                    </td>
                                    <td>
                                        <select name="status" id="status">
                                        {select_options}
                                        </select>
                                    {/status_menu}
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="entry_date">Voorstelling tijd en datum</label>
                                    </td>
                                    <td>
                                        <input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="expiration_date">User input verloop datum</label>
                                    </td>
                                    <td>
                                        <input type="text" name="expiration_date" id="expiration_date" value="{expiration_date}" maxlength="23" size="25" />
                                    </td>
                                </tr>
                                {!--<tr>
                                    <td>
                                        <label for="comment_expiration_date">Commentaar verloop datum</label>
                                    </td>
                                    <td>
                                           <input type="text" name="comment_expiration_date" id="comment_expiration_date" value="{comment_expiration_date}" maxlength="23" size="25" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="checkbox">Allow Comments</label>
                                    </td>
                                    <td>--}
                                        <input type="hidden" name="allow_comments" value="y" {allow_comments} />
                                    {!--</td>
                                </tr>--}
                                <tr>
                                    <td>
                                    {category_menu}
                                        <label for="categories">Categories</label>
                                    </td>
                                    <td>
                                        <select name="category[]" id="categories" size="10" multiple="multiple">
                                        {select_options}
                                        </select>
                                    {/category_menu}
                                    </td>
                                </tr>
                            </table>
                            
                            <h2>Header afbeelding</h2>
    <p>                        {field:header_image}<br />
                            <br />
                            </p><h2>Header video</h2>
    <p>                        {field:header_video}<br />
                            <br />
                            </p><h2>Inleiding</h2>
    <p>                        {field:summary}<br />
                            <br />
                            </p><h2>Body</h2>
    <p>                        {field:body}<br />
                            <br />
                            </p><h2>Afbeeldingen</h2>
    <p>                        {field:images}<br />
                            <br />
                            </p><h2>Filmpjes</h2>
    <p>                        {field:movies}<br />
                            <br />
                            </p><h2>Gerelateerde voorstellingen</h2>
    <p>                        {field:related_shows}<br />
                            <br />
                            <input type="submit" name="submit" value="Submit" /><br />
                            </div><!-- .content_center --><br />
                            <div class="clearfloat"></div><br />
                            <br />
                            {/exp:safecracker}<br />
                            <br />
                            {if:else}

  • #4 / Mar 22, 2011 2:52pm

    Sue Crocker

    26054 posts

    Hi, Sanity11.

    There is a bug in EE2.1.3 and EE2.1.4beta that manifests with the entry date increasing an hour each time you edit.

    It happens when you’re inside DST.

    Bug Report

    Does that help?

  • #5 / Mar 22, 2011 5:21pm

    Sanity11

    314 posts

    Hi Sue, I have updated the OP this morning. I have allready found and applied that solution. The AM / PM problem is still there.

  • #6 / Mar 23, 2011 10:25am

    Sue Crocker

    26054 posts

    OK, that appears to be a separate issue. 16:49 versus 4:49 - military time versus “regular” time, right?

  • #7 / Mar 23, 2011 10:34am

    Sanity11

    314 posts

    Yep, that’s correct.

  • #8 / Mar 23, 2011 5:43pm

    Sue Crocker

    26054 posts

    Found this in the SafeCracker older forums: http://barrettnewton.com/forums/viewthread/1746/

    Looks like it was mentioned at least once, but I also added a bug report on your behalf.

    Thanks for reporting this..

  • #9 / Mar 28, 2011 12:46pm

    Pv Ledoux

    95 posts

    It is probably not related but I have a problem with a required date field:

    <input type="text" id="{field_name}" name="{field_name}" value="{field_data}" />

    When I edit an entry, it’s ok, but if I create a new one with my safecraker form, the value of the date is set to now, but I need that the users enter a date themselves.

    My current workaround is the following:

    <dd><input type="text" id="{field_name}" name="{field_name}" value="{if segment_3 != ''}{field_data}{/if}" /></dd>

    Not a big deal but not very sexy.

  • #10 / Mar 29, 2011 7:57am

    John Henry Donovan

    12339 posts

    Pv Ledoux,

    Are you on the most recent versions of SC and EE also?
    Can you share the rest of your template so we can try and replicate this one please?

  • #11 / Mar 29, 2011 8:30am

    Pv Ledoux

    95 posts

    Hi John,

    I’m on EE 2.1.3 (Build: 20101220) and Safecraker 2.0 (Build: 20110224).

    Here is the template. Hope it is readable, there are some custom plugins in there.

    The date field is on line 62.

    Regards,

    Pv

  • #12 / Mar 29, 2011 5:55pm

    Brandon Jones

    5500 posts

    Pv Ledoux,

    Can you try this on a very simplified template without other plugins?

  • #13 / Mar 30, 2011 12:13pm

    Pv Ledoux

    95 posts

    Hi Brandon,

    here is a purified template:

    {exp:safecracker channel="video" entry_id="{segment_3}" return="/backoffice/video/" error_handling="inline"}
    
    {global_errors}<div class="error-box">{error}</div>{/global_errors}
    {field_errors}<div class="error-box">{error}</div>{/field_errors}
    
    <div id="main">
    
            
            <h1>{if "{title}" == "" }Create{if:else}Edit{/if} - Video</h1>
                        {custom_fields}
                                {if date}
                                <dl>
                                    <dt><label for="{field_name}">{field_label}{if required} *{/if}:</label></dt>
                                    <dd><input type="text" id="{field_name}" name="{field_name}" value="{field_data}" /></dd>
                                </dl>
                                {if:else}
                                    <dl>
                                        <dt><label for="{field_name}">{field_label}{if required} *{/if}:</label></dt>
                                        <dd>{display_field}</dd>
                                    </dl>
                                {/if}
                        {/custom_fields}
                
            <input type="submit" value="Submit" />
    </div>
    
    {/exp:safecracker}

    Same problem, the displayed date in the required field is set to now. And I have been noticed by a client that if a date field (not required) is left empty, the date is set to 1969-12-31 19:00.

    Regards,


    Pv

  • #14 / Mar 30, 2011 6:00pm

    Sue Crocker

    26054 posts

    I can replicate that the date field is filled in with the now value, but the same fields aren’t filled in automagically in a regular entry from inside the control panel.

    Pv, I’m not sure if that is by design or a bug. Let me go ask, it could go either way.

  • #15 / Mar 30, 2011 6:15pm

    Sue Crocker

    26054 posts

    Spoke with Robin - this is the expected behavior for SafeCracker. However, it may not be the best way of approaching things.

    I’d tend to do a Feature Request for the following:

    If the date field is required, put in the current time. If it isn’t, leave it blank. But that’s me.. your users may have other needs.

    Pv and Sanity11, whatcha think?

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

ExpressionEngine News!

#eecms, #events, #releases