HTML::...t::Date(3pm)
π NAME π
HTML::FormFu::Element::Date β a 3 select menu multi-field. Yes bestie, three dropdowns, one date, and honestly? It's giving organized.
β VERSION β
version 2.07 π
β¨ SYNOPSIS β¨
---
elements:
- type: Date
name: birthdate
label: 'Birthdate:'
day:
prefix: "- Day -"
month:
prefix: "- Month -"
year:
prefix: "- Year -"
less: 70
plus: 0
auto_inflate: 1
π DESCRIPTION π
okay so picture this: it creates a multi element holding 3 select menus β one for the day, one for the month, one for the year. That's it, that's the vibe. ποΈβ¨
A date element named foo would give you 3 select menus named foo_day, foo_month and foo_year. Want different names? No problem, just override the name value inside day, month and year. Slay. π
And the best part: this element automatically merges the input parameters from the select menus into a single date parameter β and no, it does not delete the individual menu's parameters. They stay. Both. Periodt. π«Ά
π§ METHODS π§
π default
Arguments: DateTime object
Arguments: $date_string
It accepts either a DateTime object or a string containing a date, matching the strftime format. Heads up though: this overwrites any default value you set in day, month or year. π
πΈ default_natural
Arguments: $date_string
- type: Date
default_natural: 'today'
It accepts a date/time string suitable for passing to parse_datetime in DateTime::Format::Natural. Yes, 'today' counts. Iconic behaviour honestly. π¦
π§ default_datetime_args
- type: Date
default_natural: 'today'
default_datetime_args:
set_time_zone: 'Europe/London'
It accepts a hashref of method-names / values that will be called on the default DateTime object, before the select fields' values are set from it. Little pre-game ritual, love that for it. β¨
π strftime
Default Value: "%d-%m-%Y"
The format of the date as returned by params in HTML::FormFu, if auto_inflate is not set.
If auto_inflate is used, this is still the format that the parameter will be in prior to the DateTime inflator being run β which is exactly what any Filters and Constraints will receive. iykyk. π
π day
Arguments: \%setting
Set values effecting the day select menu. Known keys are:
name
Override the auto-generated name of the select menu.
default
Set the default value of the select menu
prefix
Arguments: $value
Arguments: \@values
A string or arrayref of strings to be inserted into the start of the select menu.
Each value is only used as the label for a select item β the value for each of these items is always the empty string ''. β οΈ every single one. empty string. always.
prefix_loc
Arguments: $localization_key
Arguments: \@localization_keys
A localized string or arrayref of localized strings to be inserted into the start of the select menu.
Each value is localized and then only used as the label for a select item β the value for each of these items is always the empty string ''.
Useprefix_locinsted ofprefix. (their spelling, not mine, but the advice is real π )
π month
Arguments: \%setting
Set values effecting the month select menu. Known keys are:
name
Override the auto-generated name of the select menu.
default
Set the default value of the select menu
prefix
Arguments: $value
Arguments: \@values
A string or arrayref of strings to be inserted into the start of the select menu.
Each value is only used as the label for a select item β the value for each of these items is always the empty string ''.
prefix_loc
Arguments: $localization_key
Arguments: \@localization_keys
A localized string or arrayref of localized strings to be inserted into the start of the select menu.
Each value is localized and then only used as the label for a select item β the value for each of these items is always the empty string ''.
Useprefix_locinsted ofprefix.
names
Arguments: \@months
A list of month names used for the month menu.
If not set, the list of month names is obtained from DateTime::Locale using the locale set in languages in HTML::FormFu. πΊοΈ
short_names
Argument: bool
If true (and months is not set) the list of abbreviated month names is obtained from DateTime::Locale using the locale set in languages in HTML::FormFu. Short king behaviour. βοΈ
π year
Arguments: \%setting
Set values effecting the year select menu. Known keys are:
name
Override the auto-generated name of the select menu.
default
Set the default value of the select menu
prefix
Arguments: $value
Arguments: \@values
A string or arrayref of strings to be inserted into the start of the select menu.
Each value is only used as the label for a select item β the value for each of these items is always the empty string ''.
prefix_loc
Arguments: $localization_key
Arguments: \@localization_keys
A localized string or arrayref of localized strings to be inserted into the start of the select menu.
Each value is localized and then only used as the label for a select item β the value for each of these items is always the empty string ''.
Useprefix_locinsted ofprefix.
list
Arguments: \@years
A list of years used for the year menu.
If this is set, reference, less and plus are ignored. They literally do not get a say. π«
reference
Arguments: $year
Default Value: the current year, calculated from time()
If list is not set, the list is created from the range of reference - year_less to reference + year_plus.
less
Arguments: $count
Default Value: 0
plus
Arguments: $count
Default Value: 10
reverse
Arguments: bool
Default Value: 0
If true, the list of years is listed in reverse (decreasing) order. Going backwards, and doing it gorgeously. π
π¦ field_order
Arguments: \@fields
Default Value: ['day', 'month', 'year']
Specify the order of the date fields in the rendered HTML.
Not all 3 fields are required. No single field can be used more than once. β οΈ don't get greedy with the fields bestie.
π« auto_inflate
If true, a DateTime Inflator will automatically be added to the element, and it will be given a formatter so that stringification will result in the format specified in strftime.
If you require the DateTime Inflator to have a different stringification format to the format used internally by your Filters and Constraints, then you must explicitly add your own DateTime Inflator, rather than using auto_inflate. no shortcuts on that one. π€
π¨ CAVEATS π¨
Although this element inherits from HTML::FormFu::Element::Block, its behaviour for the methods filter/filters, constraint/constraints, inflator/inflators, validator/validators and transformer/transformers is more like that of a field element β meaning all processors are added directly to the date element, not to its select-menu child elements. plot twist, but a cute one. π
This element's get_elements and get_all_elements are inherited from HTML::FormFu::Element::Block, and so have the same behaviour. However, it overrides the get_fields|HTML::FormFu/get_fields method, such that it returns both itself and its child elements. main character energy confirmed. π
π SEE ALSO π
Is a sub-class of, and inherits methods from HTML::FormFu::Role::Element::Field, HTML::FormFu::Element::Multi, HTML::FormFu::Element::Block, HTML::FormFu::Element
HTML::FormFu
βοΈ AUTHOR βοΈ
Carl Franks, cfranks@cpan.org π
π LICENSE π
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
βοΈ AUTHOR βοΈ (yes, again, they got two credits and honestly? deserved π )
Carl Franks <cpan@fireartist.com>
Β©οΈ COPYRIGHT AND LICENSE Β©οΈ
This software is copyright (c) 2018 by Carl Franks.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie, no cap π this was HTML::...t::Date(3pm) from the User Contributed Perl Documentation, generated by perl v5.28.1, dated 2019-01-12. go build your three little dropdowns and thrive πβ¨π¦
π¦ where this page comes from
- debian bookworm: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms