[html-formfu] Taking default value when not supplied in query (plaintext)

Carl Franks fireartist at gmail.com
Tue Oct 19 15:56:42 GMT 2010


Hi,

> While the plugin approach works for many field types, it doesn't work
> for others, like this Date element:

>        retain_default: 1

That's because the Date element doesn't have a default() set.
The plugin would need to be changed to support elements that have a
retain_default() method.

> This field nicely defaults to today when rendered, but if its form is
> submitted without this field, params will not contain it, nor its
> default even though retain_default is hinting that it should.

> Am I mistaken that there should be a way to propagate default values
> for fields that weren't submitted into the post-processed hash of
> fields in a way that has that hash have the same fields and values as
> used to generate the form html?

Are you mistaken there should be a way?
Well, it's possible to provide that behaviour, but so far you're the
first person to want it.
There's not really any *should* about it.

retain_default() is documented as only affecting the rendered HTML, it
simply doesn't do what you want it to.

Any solution would require something other than just setting
retain_default(), so as to not needlessly change behaviour for anyone
currently using retain_default().

My preference would be providing the behaviour in a Plugin, such as I
previously posted - rather than adding another method to $form and
complicating the core code - for a non-common behaviour.

Carl



More information about the HTML-FormFu mailing list