FLOW3 action parameters and arrays of objects
FLOW3 provides a convenient way to pass entities by ID in the URL, and get them automatically instantiated in the controller action's parameters:
class PostController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
public function editAction(Post $post) {
...
}
}
But what about the use case where you have checkboxes, each representing a particular object? It would be handy to get them autoinstantiated as well:
<input type="checkbox" name="tags[]" value="1" />
<input type="checkbox" name="tags[]" value="2" />
...
Is there a way to tell FLOW3 to auto-instantiate the $tags
variable as an array of Tag
objects? Something like:
public function setTagsAction(Post $post, /** @var Model\Tag */ array $tags) {
$post->setTags($tags);
}
/**
* @param Post $post
* @param \Doctrine\Common\Collections\ArrayCollection<\your\namespace\Model\Tag> $tag
*/
public function setTagsAction(Post $post, $tags) { ...
afaik Doctrine will convert your array to a Collection Holding Objects mapped by the provided array