I'm using floppyforms with modelforms, and the only documentation on them is to specify widgets via the class Meta. However, I want my textarea widget placeholder to depend on a form variable, and Meta doesn't have access to class variables. Any tips on achieving this in the framework as is?
Right now I've got this in forms.py:
class ChapterForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.placeholder = "Chapter " + (kwargs.pop('number'))
super(ChapterForm,self).__init__(*args, **kwargs)
class Meta:
model = Chapter
fields = ("name", "text", ...)
widgets = {
"name": PlaceholderInput(attrs={'placeholder':self.placeholder, 'class':'headline'}),
}
I realize I could use standard (non modelforms) forms and declare the fields/widgets using variables, but was wondering if there's a way to do it without sacrificing model validation.