Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Helper methods
Mattia Roccoberton edited this page May 2, 2023
·
2 revisions
A support class can be provided for helper methods used to present the field values. Sample:
helper_class: AdminUtilsThen define the class:
classAdminUtils < TinyAdmin::Supportclass << selfdefcompact_datetime(input,options: [])input ? input.strftime(options&.first || '%Y-%m-%d %H:%M') : ''enddeflabel_for(value,options: [])options&.first ? ::I18n.t(options.first,default: value) : valueendendendAnd to use an helper method:
sections:
- slug: postsname: Poststype: resourcemodel: Postindex:
attributes:
- id
- title
- created_at: compact_datetime, %Y%m%d