Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » $dataFieldByName(MyDateField) - not using calendar

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1138 Views
  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    $dataFieldByName(MyDateField) - not using calendar Link to this post

    Hi,

    I want to render a form in a custom way and keep the popup calendar. I am using 2.4.2 and the code for the form is as follows...

    public function MyDateForm()
    {
       $fields = new FieldSet();

       $dfFrom = new DateField('DateFrom', 'DateFrom');
       $dfFrom->setConfig('showcalendar', true);
       $dfFrom->setLocale('en_GB');
       $dfFrom->setConfig('dateformat', 'YYYY-mm-dd');

       $fields->push($dfFrom);

       $actions = new FieldSet(new FormAction('StartDate', 'StartDate'));
       return new Form($this, "DateForm",$fields,$actions);
    }

    the calendar popup is not added if I try and customise the form output, can anyone see anything in the later two exaples that would enable it?

    does work, but does not allow customisation of the form...

    <div id="LeftPane">
       $MyDateForm
    </div

    does not work

    <div id="LeftPane">
       <% control MyDateForm %>
          <form $FormAttributes>
             <fieldset>
                <p>
                   $dataFieldByName(DateFrom)
                </p>
                <p class="Actions">
                   <% control Actions %>
                      $Field
                   <% end_control %>
             </fieldset>
          </form>
       <% end_control %>
    </div>

    also does not work...

    <div id="LeftPane">
       <% control MyDateForm %>
       <form $FormAttributes>
          <fieldset>
             <% control Fields %>
                 <p>
                   $Title
                   <br />
                   $Field
                </p>
             <% end_control %>

             <p class="Actions">
                <% control Actions %>
                   $Field
                <% end_control %>
             </p>
          </fieldset>
       </form>
       <% end_control %>
    </div>

    Any help is much appreciated!

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: $dataFieldByName(MyDateField) - not using calendar Link to this post

    Hi,

    Is jquery included in your header and is the jscript for the calendar field in your website's sourcecode?

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: $dataFieldByName(MyDateField) - not using calendar Link to this post

    Thanks bartvanirsel!

    That helped - the following JavaScript is in the $MyDateForm - but not the others...

    http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js
    http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/i18n/jquery.ui.datepicker-en-GB.min.js
    http://localhost/aoa/sapphire/thirdparty/jquery-metadata/jquery.metadata.js?m=1268274558
    http://localhost/aoa/sapphire/javascript/DateField.js?m=1278917861

    I've had a search for them and they relate to the date field... but I'm struggling to see why one date filed gets created and the other doesn't as it must go through the same code... but that is a great hint, thanks again.

    1138 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.