﻿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
27161	TypedChoiceField fails to validate properly when used with ArrayField	Roman Karpovich	Rômulo Rosa Furtado	"Example model:

{{{
from django.contrib.postgres.fields import ArrayField

class ArrayFieldTestModel(models.Model):
    CHOICES = map(lambda x: (x, str(x)), range(10))

    test_field = ArrayField(models.IntegerField(choices=CHOICES), blank=True, null=True)

}}}


On form saving we'll got validation error for valid choices: 
[[Image(https://snag.gy/DGNVtR.jpg)]]

This is caused by validation ordering:
1. TypedChoiceField clean method called
2. Field clean method called (super)
3. to_python method called, which should transform value to correct, but it doesn't.
3. TypedChoiceField validate called, which raise ValidationError: no such choice. He is trying to find string value in integers array and can't do this.
4. after super clean method, TypedChoiceField is trying to coerce value (it's too late, error was raised before this).

this can be easily fixed by moving _coerce call into `to_python`."	Bug	closed	Forms	dev	Normal	fixed	TypedChoiceField	jeroen@…	Accepted	1	0	0	0	0	0
