Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cols,rows and size attribute, default type is text and label can be ommited #16

Merged
merged 5 commits into from
Nov 12, 2015
Merged

Support for cols,rows and size attribute, default type is text and label can be ommited #16

merged 5 commits into from
Nov 12, 2015

Conversation

hwmaier
Copy link
Contributor

@hwmaier hwmaier commented Nov 11, 2015

I added a few small additions to the form plugin which may be useful for others:

  • Added support for the size attribute of input fields
  • Added support of the rows and cols attribute of textfields
  • Made the text field the default type so the the type field can be ommitted in the form declaration
  • Added the option to omit the label declaration. The label then defaults to the field name with the first letter in upper case (eg field name address becomes label Address)

This makes form declarations more concise as type: text and most trivial labels can be omitted.

@hwmaier
Copy link
Contributor Author

hwmaier commented Nov 12, 2015

Also added a bugfix today to this PR where the textfield name attribute appeared double in the generated output

flaviocopes added a commit that referenced this pull request Nov 12, 2015
Support for cols,rows and size attribute, default type is text and label can be ommited
@flaviocopes flaviocopes merged commit 50a6eb3 into getgrav:develop Nov 12, 2015
@flaviocopes
Copy link
Contributor

👍

@hwmaier hwmaier deleted the feature/some-enhancements branch November 12, 2015 08:31
@hwmaier
Copy link
Contributor Author

hwmaier commented Nov 12, 2015

I just saw that <textfield> has a class attribute class="input" applied. This would clash with {% if field.classes is defined %}class="{{ field.classes }}" {% endif %} which sets the class attribute a second time. Isn't the class=input attribute redundant? But I am not sure if this input class is used in some themes so was reluctant to remove it.

@hwmaier
Copy link
Contributor Author

hwmaier commented Nov 12, 2015

Sorry one more regards textfields. All other fields have this {% if field.validate.message %}title="{{ field.validate.message|e|t }}" but textfields handle the message differently, in particular the messages are not run through the escape filter. I just had a " in my message which then stuffs up the whole HTML. Could we use the same {% if field.validate.message %}title="{{ field.validate.message|e|t }} in textfields as well?
`

@flaviocopes
Copy link
Contributor

Good catch, fixed in 71c1e62

@hwmaier
Copy link
Contributor Author

hwmaier commented Nov 13, 2015

While working with forms I realized that the introduction of the size attribute for the input field with https://github.com/hwmaier/grav-plugin-form/commit/28b0acedea9c4c2d58bc25bc52a70467347cac98 is clashing with using size as a general css style in the form field's div wrapper. Like large for example in this context <div class="form-input-wrapper {{ field.size }}">. At present if somebody sets size to large, the large also would be passed to the input tag which generates invalid html. See field.html.twig.

Maybe we should remove it again or can this be resolved somehow? What do you think?

Added as issue here so it does not get forgotten:
#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants