Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

How to make Date Picker in frontend work


Go to End


6 Posts   3697 Views

Avatar
_Jam_

Community Member, 9 Posts

24 January 2011 at 3:37am

Hi,

Sorry if this might sound stupid but I have been trying to make datepicker in my custom form for my site. I have been searching the net already but I cant seem to find any guide on how to make this work. Please help me on this cause im new to silverstripe. Thanks in advance.

John

Avatar
mmh

Community Member, 24 Posts

24 January 2011 at 4:02am

Try:

$dateField = new DateField('DateField', 'DateField);
$dateField->setConfig('showcalendar', true);

Avatar
_Jam_

Community Member, 9 Posts

24 January 2011 at 4:12am

Hi mmh, This is my form function but there something that seems to be lacking cause i don't get any errors but the datepicker is still not working

function Form() {

$datefield = new DateField( "Birthday" );
$datefield->setConfig( "showcalendar", true );

$form = new Form($this, "Form", new FieldSet(

// List your fields here
new TextField("FirstName", "First name"),
new TextField("LastName"),
new TextField("Gender"),
$datefield,
new EmailField("Email", "Email address"),
new PasswordField("Password", "Password"),
new PasswordField("Password2", "Retype Password"),
new TextField("BusinessName","Business Name"),
new TextareaField("BusinessLocation", "Business Address")

), new FieldSet(

// List the action buttons here
new FormAction("SignupAction", "Submit","","","button-sign-up")

), new RequiredFields( "Email", "FirstName", "Surname" )
);
$protector = SpamProtectorManager::update_form($form, 'Captcha');
return $form;
}

Avatar
mmh

Community Member, 24 Posts

24 January 2011 at 5:39am

Hi nhoj,

I've tested the code in one blank site - everything works as expected (in SS 2.4.4)...

Attached Files
Avatar
_Jam_

Community Member, 9 Posts

24 January 2011 at 7:34am

It seems to be a css issue because its working when I switch my theme to blackcandy :/

Avatar
_Jam_

Community Member, 9 Posts

24 January 2011 at 7:44am

I got it working now. there was problem with my css

Thanks mmh :)