diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 8033c37f6..3fa1f456d 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -225,7 +225,10 @@ class AutorForm(ModelForm): self.fields['autor_related'].choices = [ (self.instance.autor_related.pk, self.instance.autor_related)] - self.fields['q'].initial = self.instance.nome + self.fields['q'].initial = '' + + self.fields[ + 'autor_related'].initial = self.instance.autor_related if self.instance.user: self.fields['username'].initial = self.instance.user.username diff --git a/sapl/templates/base/autor_form.html b/sapl/templates/base/autor_form.html index 7df595493..a15b019b8 100644 --- a/sapl/templates/base/autor_form.html +++ b/sapl/templates/base/autor_form.html @@ -1,3 +1,4 @@ + {% extends "crud/form.html" %} {% load i18n %} {% block extra_js %} @@ -40,6 +41,7 @@ $(document).ready(function(){ if (atualizar) { var radios = $("#div_id_autor_related .controls").html(''); data.models.forEach(function (val, index) { + var html_radio = '
'; radios.append(html_radio); }); @@ -63,6 +65,11 @@ $(document).ready(function(){ } else{ $('#id_nome, #id_q').val(''); + if ($('input[name=autor_related]').length == 1 ) { + $('input[name=autor_related]').prop('checked', 'checked'); + $('input[name=autor_related]').closest('.radio').addClass('checked'); + } + } }).fail(function(data) { active('nome', atualizar); @@ -132,7 +139,8 @@ $(document).ready(function(){ }); $('input[name=action_user]:checked').trigger('change'); - $('input[name=autor_related]').closest('.radio').remove(); + if (flag_create) + $('input[name=autor_related]').closest('.radio').remove(); var pk = $('#id_tipo').val(); if (pk)