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

François Suter fsu-lists at cobweb.ch
Mon Apr 11 17:20:13 CEST 2011


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


More information about the TYPO3-project-typo3v4mvc mailing list