21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 927 Views |
-
Frontend form fields

10 July 2011 at 10:26pm Last edited: 10 July 2011 10:40pm
I am using the memberprofile module. To add a date field for Date of Birth and a Gender dropdown, I have extended the Members class by doing the following:
class Customregfields extends DataObjectDecorator{
function extraStatics(){
return array(
'db' => array(
'Gender' => "Enum(',Male,Female','')",
'DOB' => "Date"
);
}
}What do I need to do to achieve the following?
1. Have the Date of Birth field display in the frontend registration form as three dropdowns Day, Month, Year.
2. Change the Gender dropdown to radio buttons. -
Re: Frontend form fields

11 July 2011 at 8:23pm
Hi Tee808,
This should work for (1), but I don't have an answer for (2)... hope it helps!
function getCMSFields() {
$fields = parent::getCMSFields();
$df = new DateField('DOB','Date Of Birth');
$df->setConfig('showcalendar', true);
$df->setLocale('en_GB');
$df->setConfig('dateformat', 'dd/MM/YYYY');$fields-replaceField('DOB',$df);
return $fields;
}Note I am in the UK, so I use UK date format and I believe the (very confusing to me) US format is the default so you shouldn't need the last two lines...
-
Re: Frontend form fields

11 July 2011 at 10:45pm
Thanks for your reply. I'm not sure you understood what I am needing though.
I'm wanting three dropdowns: day, month and year.
-
Re: Frontend form fields

11 July 2011 at 10:52pm
ah, my bad, totally doesn't do that, it can provide three boxes - but I wrote a massive amount of custom code to do three dropdowns - not something that can be summed up in three lines... sorry for the confusion...
-
Re: Frontend form fields

5 December 2011 at 4:11am
I have just gone back to revaluate my code and found this...
https://github.com/sunnysideup/silverstripe-form-fields
...thought I'd update the thread
| 927 Views | ||
|
Page:
1
|
Go to Top |


