HTML::...tValue(3pm)

πŸ“¦
version 2.07000 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

HTML::FormFu::Filter::ForceListValue β€” the little filter that turns one lonely value into a list with exactly one item in it πŸŽ€

It's a HTML::FormFu filter, bestie. It lives in the HTML::FormFu::Filter:: namespace and it is so specific and it knows it.


✨ VERSION ✨

version 2.07 πŸ’…


🌸 SYNOPSIS 🌸

okay so here's how you'd actually use it, in your form config YAML:

element:
  - type: Repeatable
    increment_field_names: 0
    elements:
      - name: foo
        render_processed_value: 1
        filter:
          - ForceListValue

see how it's just chillin' in the filter list? yeah. that's the whole vibe πŸ¦‹


🫢 DESCRIPTION 🫢

So what does it do? It takes a single submitted value and changes it into a list containing 1 item. that's it. that's the job. one value in, a 1-item list out. iconic behaviour, no notes ✨

Now here's why you'd ever want that β€” it solves a very uncommon problem with a Repeatable block when increment_field_names is disabled, and you're manually increasing the repeat count after the form was submitted with only a single value for each of the Repeatable's fields. niche? yes. real? also yes 😭

In those exact circumstances, when the thing gets rendered, every repeated field would have the initially-submitted value as its default. like, every single one. the whole gang. not the move πŸ’€

So you use this filter, and you set render_processed_value to "true", and then β€” slay β€” only the first repetition of each field will have the submitted value as its default. Every repetition after that? no default value. nothing. clean slate 🧚

πŸ’‘ lowkey the key detail here is render_processed_value being set to "true" β€” the filter and that setting are doing this together, periodt.

πŸ‘‘ AUTHOR πŸ‘‘

Carl Franks


πŸ“œ LICENSE πŸ“œ

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’œ


πŸ’Œ AUTHOR πŸ’Œ

Carl Franks <cpan@fireartist.com>

(yeah, they're listed twice in this page. not a typo on my end, bestie β€” that's just how the original is built πŸ™ˆ)


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, fr fr πŸ’– go forth and make your Repeatable fields behave. mwah πŸŽ€

this little writeup is from perl v5.28.1, dated 2019-01-12 β€” and the manual it's a part of is HTML::...tValue(3pm). catch u in the next one πŸ¦‹

πŸ“¦ where this page comes from