NouanceLabs / payload-better-fields-plugin

This plugin aims to provide you with very specific and improved fields for the Payload admin panel.
MIT License
124 stars 2 forks source link

Can't hide or control access for Date TimeZone field #78

Open skysarwer opened 1 month ago

skysarwer commented 1 month ago

The following will not work :


...DateField(
              {
                name: "my_date",
                label: "My Date",
                required: true,
                defaultValue: () => new Date(new Date().getFullYear(), 0, 1),
                admin: {
                  date: {
                    displayFormat: "MMMM dd",
                  },
                },
              },
              {
                // here are the timezone settings
                enable: true,
                overrides: {
                  name: "my_timezone",
                  required: true,
                  defaultValue: "America/New_York",
                  admin: {
                    // this will not work
                    hidden: true,
                  },
                  // this will not work
                  access: {
                    update: () => false,
                  },
                },
              }
            ),

Being able to set overrides.access and overrides.admin.hidden to the timezone parameter of the field, and have the options impact the timezone select component would be amazing. custom alternative params outside of overrides would be an equally viable option.

We may not always want to allow the user to select a timezone, but just set one by default (and have it display that way accordingly).

A much nicer to have goal in this same vein would be if we could somehow set a timezone parameter to the date field based on the document data (such as different timezone fields, timezones within relationships, etc).