Hi,
does anybody know how can I allow different kind of datetypes in one form?
I need an exact date with day, month and year but also only the year.
Is this possible to do with only one blueprintform or need I both?
Cheers
Hi,
does anybody know how can I allow different kind of datetypes in one form?
I need an exact date with day, month and year but also only the year.
Is this possible to do with only one blueprintform or need I both?
Cheers
First of all you should always store the date in the most exact format you need. So if you need both year and year/month/day, you should store it in the latter format.
You can then extract the year from the exact date like so:
echo $page->date('Y');
Hello Lukas,
this is the output style but I mean in the panel.
Sorry I was not clear enough.
Do you just need people to select a year?
You could go for a number field
year:
type: number
default: 2016
label: select Year
Hi,
also the situation is that I have information with a normale date (dd.mm.yy) and information with only years without day or month info.
So now I want to have only one field for different date information. The numberfield makes it not possible to prevent wrong dateinformation or serve a calendarpopup. This is the reason why I ask if its possible to use different datetypes in one form?
Cheers
So what you say is that some pages only have a year and some a full date? Isn’t that a bit inconsistent?
I’m not sure I understand what you’re asking for
If @lukasbestle got it right, it feels inconsistent indeed.
I don’t see the need for a calendar to pop-up to select a year. You could use validation on the number field to make sure that it’s for instance between 1901 and 2020.
If what you need is really an incremental calendar, you may want to build your own field based on the date picker field.
Hi,
yes it is inconsitent but the data are what the data are :).
I want the popup not for the year but for the date input inside the same field and I don’t want to use a normal field because I have a DAU as user and I can’t proof that the user is not input some wrong information there.
But if its not possible than it is how it is :).
And to develop an own field is not possible because my timesheet is full.
Cheers and thank you.
I’m also not sure, if I understand your problem correctly, but what about 3 separate select fields – year, month and day. You have to do some validation (does 31st exist in this month, …?) before rendering the result in your template, but it may be a solution.