我正在使用媒体库作为文件字段。我的表单中有两个字段custom_url和media字段,需要填充custom_url或媒体。
我正在使用laravel验证和required_without规则验证表单,该规则如下所示。
我用的是新星包。
Text::make(__('Custom Url'), 'custom_url')
->rules('required_without:file')
->help('Required without file upload'),
Files::make('File', 'file')
->rules('required_without:custom_url')
->help('Required without Custom URL'),
我上传文件,但尽管它显示了错误,始终自定义网址是必需的。
我认为file字段正在返回空值。有人能指点我怎么做吗?
发布于 2020-06-15 17:14:55
请检查您的迁移表和存储方法。然后查看表单字段名和迁移列名是否相同。
发布于 2020-07-02 18:31:33
您可能在表单声明中缺少了enctype="multipart/form-data"
。
所以必须是<form method="..." action="..." enctype="multipart/form-data">
https://stackoverflow.com/questions/62393345
复制相似问题