0
votes

in a extbase extension i us sys_category. In list action there is no problem, all categories work as expected. But i want to write category entries with a custom database finisher from tx_form.

In the model all seems correct:

/**
 * Sets the categories
 *
 * @param  \TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories
 * @return void
 */
public function setCategories($categories)
{
    $this->categories = $categories;
}

in my finisher:

$newAddress->setCategories($newCat);
$this->addressRepository->add($newAddress);

The form gives me only the uid of the category but for "setCategories" i need an \TYPO3\CMS\Extbase\Persistence\ObjectStorage.

How do i get a \TYPO3\CMS\Extbase\Persistence\ObjectStorage from the uid of the category?

Thanks!

1

1 Answers

1
votes

You need a setter method for the categories like this:

public function addCategory($category)
{
    $this->categories->attach($category);
}

This method will add one model to your object storage.

As you need the category model to be added, you need to get the corresponding model of the uid with $categoryRepository->findByUid($uid);