brainbuz / form-diva

Form::Diva Form Elements Generator
3 stars 2 forks source link

Generate placeholders regardless of form data availability #14

Closed bbrtj closed 2 years ago

bbrtj commented 2 years ago

Placeholders are used in text input / textarea fields, where they do not clash with actual values and only become visible when the text is deleted. Always generating them should be more consistent than doing so conditionally.

Resolves #9

brainbuz commented 2 years ago

Probably better to have an optional argument to new and or generate to toggle this with the default being off so that behaviour doesn't change if someone updates the module. As is I consider it neutral.

bbrtj commented 2 years ago

It is more of a bugfix in my view.

Imagine a minimal login form with two inputs (user / password) and no labels. User knows which is which from the placeholders. It isn't uncommon to have a minimal form that is fully described by the placeholders.

Once the form is submitted, if the login data was not valid, the form has to be prefilled to have the same data as was entered before sending. This removes placeholders, and you should only see what you entered previously. However, password field is best not sent back filled out to avoid plaintext password in the HTML document.

This results in the password field empty but without placeholder, which is certainly not desired behavior. I think it's better to provide HTML with the placeholder regardless of data and it will properly handle this and other cases.

bbrtj commented 2 years ago

I'll merge this, since it should make module behavior less surprising.