[TYPO3-mvc] How to load a list of value objects?

Sy Moen josiah.moen at gmail.com
Mon Apr 11 23:03:14 CEST 2011


I had the same issue, and eventually turned the value object select list
into a sub-table. I am interested in the "correct" answer as well.

On Mon, Apr 11, 2011 at 9:20 AM, François Suter <fsu-lists at cobweb.ch> wrote:

> Hi,
>
>
>  I have an entity which is related to one or more items that are value
>> objects. In the (Fluid) input form I would like to display the selection
>> of those items as a select field with multiple choices. How do I load
>> the list of available value objects into my select field? Since the
>> value objects have no dedicated repository class, how do I access them?
>>
>
> I've managed to solve this issue, but I've no idea whether this was the
> right way to do it, so I would appreciate if someone could comment on that:
>
>        // Get the list of sleeping drugs from the storage
>        /** @var $queryFactory Tx_Extbase_Persistence_QueryFactory */
> $queryFactory =
> $this->objectManager->get('Tx_Extbase_Persistence_QueryFactory');
>        /** @var $query Tx_Extbase_Persistence_QueryInterface */
> $query = $queryFactory->create('Tx_Latourrisk_Domain_Model_SleepingDrug');
> $result = $query->execute();
> $sleepingDrugsList = array();
>        /** @var $drug Tx_Latourrisk_Domain_Model_SleepingDrug */
> $drug = NULL;
> foreach ($result as $key => $drug) {
>        $sleepingDrugsList[$drug->getUid()] = $drug->getDrugName();
> }
>
> I did that in the controller and I then assign the $sleepingDrugsList array
> to the current view.
>
> Is that the right way to load a value objects list?
>
> Cheers
>
>
> --
>
> Francois Suter
> Cobweb Development Sarl - http://www.cobweb.ch
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>


More information about the TYPO3-project-typo3v4mvc mailing list