withAdditional(['accept' => $accept]); } return new self( metadata: new FieldMetadata($name, $label, $help), attributes: $attributes, wrapper: new FieldWrapper(), value: $value, accept: $accept ); } public function render(FormBuilder $form): FormBuilder { $input = FormElement::fileInput($this->attributes->name()) ->withId($this->attributes->id()) ->withClass($this->attributes->class()); if ($this->attributes->required()) { $input = $input->withRequired(); } if ($this->accept !== null) { $input = $input->withAttribute('accept', $this->accept); } // Add any additional attributes (skip standard ones already set) $allAttrs = $this->attributes->toHtmlAttributes(); $standardAttrs = ['name', 'id', 'class', 'required']; foreach ($allAttrs->toArray() as $name => $value) { if (!in_array($name, $standardAttrs, true) && $value !== null) { $input = $input->withAttribute($name, $value); } } $wrapped = $this->wrapper->wrap((string) $input, $this->metadata); return $form->addRawHtml($wrapped); } public function getName(): string { return $this->metadata->name; } public function getValue(): mixed { return $this->value; } public function getLabel(): string { return $this->metadata->label; } }