# Django imports. from django.forms import ModelForm from django.forms.models import inlineformset_factory # Application imports. from .models import Entity, Interface class EntityForm(ModelForm): """ Implements a custom model form for entities with some styling changes. """ class Meta: model = Entity def __init__(self, *args, **kwargs): """ Initialises the form instance. Sets-up some bootstrap CSS classes for widgets. """ super(EntityForm, self).__init__(*args, **kwargs) # Update the widgets to be wider, and set-up placeholder values for text # boxes. self.fields["name"].widget.attrs["class"] = "span6" self.fields["name"].widget.attrs["placeholder"] = "Entity name" self.fields["description"].widget.attrs["class"] = "span6" self.fields["description"].widget.attrs["placeholder"] = "Description for new entity." self.fields["project"].widget.attrs["class"] = "span6" self.fields["location"].widget.attrs["class"] = "span6"