kvesteri / wtforms-alchemy

Tools for creating wtforms from sqlalchemy models
Other
245 stars 59 forks source link

Is there a way to provide render_kw? #143

Closed CatInCosmicSpace closed 4 years ago

CatInCosmicSpace commented 5 years ago

Hello.

Is there a way to use render_kw keyword?

For example I use JS data validation library and I would like to set these attributes to StringField:

class NameForm(FlaskForm):
    name = StringField(
        'Name',
        render_kw={
            "class": "form-control ",

            "data-validation": "required"
        }
    )

I looked in the docs, but did not find.

ri-gilfanov commented 4 years ago

CatInCosmicSpace, I think so. This work for me:

class RegistrationForm(ModelForm):
    class Meta:
        model = models.User
        field_args = {
            'delivery_address': {
                'render_kw': {
                    'placeholder': 'Specify your delivery address',
                    'rows': '10',
                    'style': 'resize: vertical; height: auto;'}}}