﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34119	ModelForm fields with callable defaults don't correctly propagate default values	Benjamin Rigaud	David Sanders	"When creating an object via the admin, if an inline contains an ArrayField in error, the validation will be bypassed (and the inline dismissed) if we submit the form a second time (without modification).

- go to `/admin/my_app/thing/add/`
- type anything in `plop`
- submit -> it shows an error on the inline
- submit again -> no errors, `plop` become unfilled

{{{
# models.py

class Thing(models.Model):
    pass


class RelatedModel(models.Model):
    thing = models.ForeignKey(Thing, on_delete=models.CASCADE)

    plop = ArrayField(
        models.CharField(max_length=42),
        default=list,
    )


# admin.py

class RelatedModelForm(forms.ModelForm):
    def clean(self):
        raise ValidationError(""whatever"")


class RelatedModelInline(admin.TabularInline):
    form = RelatedModelForm
    model = RelatedModel
    extra = 1


@admin.register(Thing)
class ThingAdmin(admin.ModelAdmin):
    inlines = [
        RelatedModelInline
    ]
}}}

It seems related to the hidden input containing the initial value:

`<input type=""hidden"" name=""initial-relatedmodel_set-0-plop"" value=""test"" id=""initial-relatedmodel_set-0-id_relatedmodel_set-0-plop"">`

I can fix the issue locally by forcing `show_hidden_initial=False` on the field (in the form init)
"	Bug	closed	Forms	4.1	Normal	fixed	modelform	David Sanders	Ready for checkin	1	0	0	0	0	0
