Hide the document type field if document type is specified in the form's initial values

This commit is contained in:
Roberto Rosario
2011-02-04 01:39:39 -04:00
parent 5e524fb825
commit 6243a2f1f6
3 changed files with 13 additions and 1 deletions

View File

@@ -13,7 +13,14 @@ from models import Document, DocumentType, DocumentTypeMetadataType
from documents.conf.settings import AVAILABLE_FUNCTIONS
class DocumentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(DocumentForm, self).__init__(*args, **kwargs)
if 'initial' in kwargs:
if 'document_type' in kwargs['initial']:
self.fields['document_type'].widget = forms.HiddenInput()
class Meta:
model = Document