Forum

Thread tagged as: Problem

Date fieldorder issue

I've got a situation where I only need the month and date in a date field. I'm using the fieldorder attribute to limit the fields in the control panel to just the year and month:

<perch:content id="year" type="date" label="Date of event" fieldorder="ym" />

This looks good when editing the item in the CMS, but on the item list in the region (I've got the date field in the 'Item list column IDs' region option) it's losing the date entirely and setting the date to the default 1970. Also, it's not outputting the date to the site.

The fieldorder thing was a 'eureka' moment as I've had to output just a year to a site before and had to hide the month and day inputs in the control panel using some custom CSS in perch/addons/plugins/ui/ which felt a bit nasty. But it was necessary to keep the control panel UI clean and intuitive. I suppose a type="select" would serve, but the month and year would be on two lines and it would need a lot of options in the options="" attribute.

I guess this isn't truly a bug, but it would make my day if you were to allow just any one/two of the year, month and date, rather than just reordering them.

Thanks for taking a look :)

Martin Underhill

Martin Underhill 5 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't omit parts of a date - the reordering functionality is to allow for preference of month-day-year, or year-month-day etc.

If you leave fields out, it'll break.

Ah ok. Thought so. Is there a possibility you could amend the functionality slightly in 2.8.32 to allow bits of the date…? So fieldorder="ym" would output the year and date in the CMS (as it does at the moment) and it outputs the year and month to the website (this is where it breaks at the moment)? Or fieldorder="y" for just the year, etc.

No worries if not something you'd consider, but doesn't hurt to ask ;)

Thanks :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

The way to do it right now is to create a custom field type to handle it.

Gotcha. No idea how I'd do that with my meagre php chops, so I'll fall back on altering the control panel's CSS for now :)