Gero Langheim
Gero Langheim

Reputation: 11

TYPO3 Extbase: Save titles sorted in frontend (TYPO3)

I have a table tx_bla_domain_model_offer

in the title field I store several titles from tx_bla_domain_model_blubtitle with tx_bla_blub_title_mm

The first time I save everything is correct, I can sort the titles as I want and it keeps everything sorted.

Only, if I want to sort the same titles differently, it keeps the old sorting when saving...

Sorting in $_POST['tx_bla']['offer']['offerTitle'] is correct. Sorting in $this->arguments->getArgument('offer')->getValue()->getOfferTitle() is not correct.

In tx_bla_blub_title_mm the sorting does not change...

In the TCA is set foreign_sortby, but it haves no effect...

Upvotes: 1

Views: 66

Answers (2)

Gero Langheim
Gero Langheim

Reputation: 11

The Solution is create a empty Object and add the new titles.

    $offer->setOfferTitle(new \TYPO3\CMS\Extbase\Persistence\ObjectStorage);
    foreach ($_POST['tx_bla_jobs']['offer']['offerTitle'] as $titleUid) {
        $offer->addOfferTitle($this->offertitleRepository->findByUid($titleUid));
    }

Upvotes: 0

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10790

Have you read the attention section at foreign_sortby?

Probably you want to use foreign_default_sortby

Upvotes: 1

Related Questions