https://avo.cool logo
Hi! I couldn't find any mention of this here/on...
# avo-3
e
Hi! I couldn't find any mention of this here/on GitHub, and in the [code](https://github.com/avo-hq/avo/blob/cb38252b21b64818cf7ac0bc070c518553333984/lib/avo/fields/date_time_field.rb#L14), it looks like it's just hardcoded. But I want to confirm - is it possible to set a default date/time format for all such fields?
m
Thread automatically created by Volodymyr in #1138182212655788054
l
hi @early-knife-34520 there isn't a configurable way to achieve that, but what I would do is to override the
def field
method on the base resource and set the default there
e
It's one way, but it requires updating 30+ resources Can I submit a feature request on GitHub for this?
l
Not 30+ resources
Only on the base resource
The feature request to configure default for field options can be tracked here: https://github.com/avo-hq/avo/issues/2699
e
Ah, I see. Makes sense, tho I still think having separate config optin would work better for dates In this case, there is one method for all types, and if I want to support additional options (e.g., override the format for this particular field), I need to add these checks too
l
Agree, where do you imagine configuring this?
e
I left a comment under this issue https://github.com/avo-hq/avo/issues/2699#issuecomment-3586598960 I see it like that
Copy code
Avo.configure do |config|
  config.date_format = "dd.LL.yyyy"
  config.time_format = "dd.LL.yyyy HH:mm"
end
But any place would work
What I like about overriding
field
in
Avo::BaseResource
is that I can choose the format based on the current user (assuming I have access to it there)
l
I was thinking about this configuration to be more specific,
config.something
normaly is a global config
and here
date_format
and
time_format
are field options for a subset of fields
so maybe something that can indicate the fiedl type where to apply
thanks for the feedback!
maybe something like
Copy code
ruby
Avo.configure do |config|
  config.field_options_default = {
    date_format: "dd.LL.yyyy",
    time_at: ...,
    ...
  }
end
e
> config.something normaly is a global config Agree and
Copy code
...
config.field_options_default = {
    date_format: -> { current_user.time.zone.format 
    }
...