Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requiredIf not working with FileUpload component #15954

Open
mariavilaro opened this issue Mar 27, 2025 · 0 comments
Open

requiredIf not working with FileUpload component #15954

mariavilaro opened this issue Mar 27, 2025 · 0 comments
Labels
Milestone

Comments

@mariavilaro
Copy link

Package

filament/filament

Package Version

v3.3.3

Laravel Version

v12.1.1

Livewire Version

v3.6.1

PHP Version

PHP 8.4.5

Problem description

In a form with a select with two options and two dependent fields: a fileupload and a richeditor. Using requiredIf(), when the selected option is "1" the fileupload field is required, and when the selected option is "2" the richeditor is required.

The problem is that the fileupload is not required correctly, and you can create a record with type "1" without uploading anything. When selecting type "2" the richeditor is required so you can't create a record with type "2" and no text.

The fileupload is always required if you use ->required(), so I think this is a problem just with the conjuntion fileupload + requiredIf().

Expected behavior

You shouldn't be able to submit the form if you choose "1" in the select and don't upload the file, and the error message "The file field is required when type is 1" should appear.

Steps to reproduce

use Filament\Forms;

Forms\Components\Select::make('type')
    ->required()
    ->options([
        1 => trans('File'),
        2 => trans('Text'),
    ]),
Forms\Components\FileUpload::make('filename')
    ->requiredIf('type', 1),
Forms\Components\RichEditor::make('text')
    ->requiredIf('type', 2)
]);

Reproduction repository (issue will be closed if this is not valid)

https://github.com/mariavilaro/filament-issue-requiredif-fileupload

Relevant log output

@github-project-automation github-project-automation bot moved this to Todo in Roadmap Mar 27, 2025
@danharrin danharrin added this to the v3 milestone Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants