{"record":{"id":"ab505aac896638bd","repo":"filamentphp/filament","slug":"field-of-class-fieldclass-must-have-a-unique-na","errorCode":null,"errorMessage":"Field of class [$fieldClass] must have a unique name, passed to the [make()] method.","messagePattern":"Field of class \\[\\$fieldClass\\] must have a unique name, passed to the \\[make\\(\\)\\] method\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/forms/src/Components/Field.php","lineNumber":80,"sourceCode":"\n    const ABOVE_ERROR_MESSAGE_SCHEMA_KEY = 'above_error_message';\n\n    const BELOW_ERROR_MESSAGE_SCHEMA_KEY = 'below_error_message';\n\n    final public function __construct(string $name)\n    {\n        $this->name($name);\n        $this->statePath($name);\n    }\n\n    public static function make(?string $name = null): static\n    {\n        $fieldClass = static::class;\n\n        $name ??= static::getDefaultName();\n\n        if ($name === null) {\n            throw new InvalidArgumentException(\"Field of class [$fieldClass] must have a unique name, passed to the [make()] method.\");\n        }\n\n        $static = app($fieldClass, ['name' => $name]);\n\n        $static->configure();\n\n        return $static;\n    }\n\n    protected function setUp(): void\n    {\n        parent::setUp();\n\n        $this->setUpHint();\n    }\n\n    public static function getDefaultName(): ?string\n    {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/filamentphp/filament/blob/53483fa9340e4ec637985fe454ebb58afb92ea24/packages/forms/src/Components/Field.php#L62-L98","documentation":"Every form Field's name doubles as its state path and the array key it is saved under, so a null name is always a bug. `Field::make()` falls back to `getDefaultName()` (null in the base class) and throws an InvalidArgumentException when the result is still `null` — note the check is `=== null`, so an empty string is not caught here and fails later instead.","triggerScenarios":"`TextInput::make()` with no argument, or `TextInput::make($columnName)` where `$columnName` evaluates to null (missing array key, null config value) at schema construction time.","commonSituations":"Generating fields from database metadata or config maps where a key is absent, destructuring with a wrong variable, or copy-paste where the name got deleted.","solutions":["Pass an explicit name: `TextInput::make('title')`.","Default dynamic values: `TextInput::make($column ?? $fallback)`.","In custom field classes, override `getDefaultName()` to return a stable identifier."],"exampleFix":"// before\nTextInput::make($column) // $column is null\n    ->required(),\n\n// after\nTextInput::make($column ?? 'title')\n    ->required(),","handlingStrategy":"type-guard","validationCode":"foreach ($columns as $key => $meta) {\n    if ($key === null) {\n        continue; // or collect for a config error report\n    }\n\n    $fields[] = TextInput::make($key);\n}","typeGuard":"function assertFieldName(?string $name): string\n{\n    if ($name === null) {\n        throw new InvalidArgumentException('Field name cannot be null.');\n    }\n\n    return $name;\n}\n\n// TextInput::make(assertFieldName($column))","tryCatchPattern":null,"preventionTips":["Default dynamic names instead of passing possibly-null variables.","Validate schema-generating config (DB metadata, YAML) for null keys before building fields.","Note the base check is === null: an empty string slips through and misbehaves later, so guard blanks too."],"tags":["filament","forms","schema","component-name","invalid-argument"],"backgroundTag":"missing-component-name","analyzedSha":"53483fa9340e4ec637985fe454ebb58afb92ea24","analyzedAt":"2026-08-17T02:06:23.049Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}