Skip to content

UUID autocomplete fails due to wrong field mapping access #7286

@MrNancy

Description

@MrNancy

When submitting an autocomplete field that uses a UUID as the entity identifier, EasyAdmin throws an error because the Doctrine field mapping is accessed as an object ($idFieldMapping->type).
However, getFieldMapping() returns an array, not an object.

This causes the UUID type check to fail, preventing correct binary conversion and breaking autocomplete submissions for UUID-based entities.

To Reproduce

  1. Use an entity where the primary key is a UUID field mapped with uuid_binary (Doctrine UuidType).
  2. Configure an autocomplete field in EasyAdmin referencing this entity.
  3. Submit the form with a selected autocomplete value.
  4. EasyAdmin triggers an error similar to:
  5. Attempt to read property "type" on array
    /**
     * Gets the mapping of a (regular) field that holds some data but not a
     * reference to another object.
     *
     * @param string $fieldName The field name.
     *
     * @return mixed[] The field mapping.
     * @phpstan-return FieldMapping
     *
     * @throws MappingException
     */
    public function getFieldMapping($fieldName)
    {
        if (! isset($this->fieldMappings[$fieldName])) {
            throw MappingException::mappingNotFound($this->name, $fieldName);
        }

        return $this->fieldMappings[$fieldName];
    }

Expected behavior

EasyAdmin should correctly detect the field type by accessing it as an array:

$idFieldMapping['type']

This allows the UUID to be converted properly:
Uuid::fromString($v)->toBinary();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions