Question

I'm building content type using dexterity. We've date of birth field and by default year range is +- 10 year from current year.

Date field need to be modify and year should start from 1950. I did bit goggling and couldn't find right information I'm after.

Below is my DOB field definition.

dob = schema.Date(
    title=_(u"Date of Birth"),
    )

Any advise or reference would be great.

Thanks in advance.

Was it helpful?

Solution

Use the collective.z3cform.datetimewidget (https://github.com/collective/collective.z3cform.datetimewidget) for your field.

This widget has a yearRange attribute. By default it gets the range defined in site_properties: calendar_starting_year and calendar_future_years_available

Check the documentation if you don't know how to setup the widget

BTW since Version 1.2.4, You can set the min/max value on the field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top