I have a product component with fields: title and description.
Inside there there is also a FileUpload subcomponent.
Considering that the FileUpload has a $files
variable that is required
when the user tries to create a new product without files I want the
file validation exception to bubble up to the product component so to cancel the creation of the product.
How can I do this?
class Product extends Component
{
public $title;
public $description;
public function rules()
{
return [
'title' => 'required',
'description' => 'required',
];
}
}
class FileUpload extends Component
{
public $files = [];
public function rules()
{
return [
'files' => 'required',
];
}
}