diff options
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r-- | archaeological_operations/forms.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index a426eaf09..efbd279ed 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -268,7 +268,7 @@ class OperationFormSelection(forms.Form): raise forms.ValidationError(_(u"You should select an operation.")) return cleaned_data -class OperationCodeInput(forms.HiddenInput): +class OperationCodeInput(forms.TextInput): """Manage auto complete when changing year in form""" def render(self, *args, **kwargs): name, value = args @@ -349,8 +349,8 @@ class OperationFormGeneral(forms.Form): validators=[validators.MinValueValidator(1900), validators.MaxValueValidator(2100)]) operation_code = forms.IntegerField(label=_(u"Operation code"), - initial=models.Operation.get_available_operation_code, - widget=OperationCodeInput) + initial=models.Operation.get_available_operation_code, + widget=OperationCodeInput(attrs={'readonly':'readonly'})) common_name = forms.CharField(label=_(u"Generic name"), required=False, max_length=120, widget=forms.Textarea) operator_reference = forms.CharField(label=_(u"Operator reference"), @@ -383,6 +383,8 @@ class OperationFormGeneral(forms.Form): super(OperationFormGeneral, self).__init__(*args, **kwargs) self.fields['operation_type'].choices = models.OperationType.get_types() self.fields['operation_type'].help_text = models.OperationType.get_help() + if kwargs and kwargs['data']: # data POSTED + self.fields['operation_code'].widget.attrs.pop('readonly') def clean(self): cleaned_data = self.cleaned_data |