[Answer]-Accessing form variables in Meta, Django Floppyforms

1👍

You can define those attributes via the field’s widget

from django.forms.widgets import TextInput

def __init__(self, *args, **kwargs):
    self.placeholder = "Chapter %s" % kwargs.pop('number')
    super(ChapterForm,self).__init__(*args, **kwargs)

    self.fields['name'].widget = TextInput(attrs={
        'class': "headline",
        'placeholder': self.placeholder
    });

Leave a comment