Add FieldCollection::setValuesFromRequest() method

This commit is contained in:
Giuseppe Criscione 2024-09-21 15:54:14 +02:00
parent 91e05505dc
commit a2d5862064

View File

@ -4,6 +4,7 @@ namespace Formwork\Fields;
use Formwork\Data\AbstractCollection;
use Formwork\Fields\Layout\Layout;
use Formwork\Http\Request;
use Formwork\Model\Model;
use Formwork\Utils\Arr;
@ -100,4 +101,13 @@ class FieldCollection extends AbstractCollection
return $this;
}
public function setValuesFromRequest(Request $request, mixed $default = null): static
{
return $this->setValues([
...$request->query()->toArray(),
...$request->input()->toArray(),
...$request->files()->toArray(),
], $default);
}
}