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

html_params and class and class_ #449

Closed
xyzones opened this issue Sep 27, 2018 · 3 comments · Fixed by #596
Closed

html_params and class and class_ #449

xyzones opened this issue Sep 27, 2018 · 3 comments · Fixed by #596
Milestone

Comments

@xyzones
Copy link

xyzones commented Sep 27, 2018

Hello,

I have a form created with model_form of flask_mongoengine.wtf

    field_args = {
      'bio': {'render_kw':{'class_':"summernote"}},
    }
    exclude = ['created_at','created_by']
    form = model_form(Author,exclude=exclude,field_args=field_args)

I have a HTML

 {{ field(class='form-control', **kwargs) }}

for which the TextArea widget correctly outputs

<textarea class="form-control" class="summernote" id="bio" name="bio">text</textarea>

However all browsers are removing the extra class tag. It would be good to rewrite the html_params so that multiple class tags are combined into one.

expected output:

<textarea class="form-control summernote" id="bio" name="bio">text</textarea>

I am using

Package Version
Flask 1.0.2
Flask-WTF 0.14.2
flask-mongoengine 0.9.5
WTForms 2.2.1

Thanks,

@davidism davidism added this to the 3.0 milestone Sep 27, 2018
@davidism
Copy link
Member

For flexibility, we'd have to allow names further down the line override the value, rather than combining, so that you can replace values rather than just append.

@azmeuk
Copy link
Member

azmeuk commented Apr 24, 2020

I could reproduce with:

>>> import wtforms

>>> class F(wtforms.Form): 
...     foo = wtforms.StringField(render_kw={'class_':'summernote'})

>>> F().foo(**{"class": "form-control"})
Markup('<input class="form-control" class="summernote" id="foo" name="foo" type="text" value="">')

@davidism are you saying that form-control should override summernote?

@davidism
Copy link
Member

I think that's what I meant, yes. Do any normalization then overwrite existing keys.

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

Successfully merging a pull request may close this issue.

3 participants