[TYPO3-mvc] Problem with understanding f:select

Manfred Rutschmann manfred.rutschmann at revier.de
Fri Dec 23 07:54:06 CET 2011


Hey guys,

i have written many extensions in extbase, but i have each time massive
problems with the f:select form tag. It does not save the object from
related objects from a related object. my scenario is the following:


Object 1 is named Card. Card has a m:n relation to object 2, Shops.
The property $shop in Card is of type ObjectStorage. This relation works
very well in be/fe.

Now, i have a third object, Mail. Mail has with the property $card a n:1
relation to the Card Object. This works to. But i need in Mail a relation
to one selected Shop from Card. My Mail model has the property $shop which
is type of the Shop Class at itself: 

	/**
	 * shop
	 *
	 * @var Tx_Mrcards_Domain_Model_Shop
	 */
	protected $shop;

	/**
	 * Returns the shop
	 *
	 * @return Tx_Mrcards_Domain_Model_Shop $shop
	 */
	public function getShop() {
		return $this->shop;
	}

	/**
	 * Sets the shop
	 *
	 * @param Tx_Mrcards_Domain_Model_Shop $shop
	 * @return void
	 */
	public function setShop(Tx_Mrcards_Domain_Model_Shop $shop) {
		$this->shop = $shop;
	}

I have a newAction and createAction for the Mail object.
New, its simple:

	/**
	 * action new
	 *
	 * @param $newMail
	 * @param $card
	 * @dontvalidate $newMail
	 * @return void
	 */
	public function newAction(Tx_Mrcards_Domain_Model_Mail $newMail = NULL,
Tx_Mrcards_Domain_Model_Card $card = NULL) {
		// start new we store the given card in the new mail object
		$newMail == NULL ? $newMail = new Tx_Mrcards_Domain_Model_Mail :
$newMail;
		
		// when the card is given store it in the new object
		$card != NULL ? $newMail->setCard($card) : $card ;

		$this->view
						->assign('newMail', $newMail)
						->assign('card', $card);
	}


in my template i have the following code:

<f:form method="post" action="create"  enctype="multipart/form-data"
arguments="{card: card}" name="newMail" object="{newMail}">

I come from a another controller action form to this one. It passes a card
object to this action/template. Now i have a select tag:

<f:form.select name="shop" options="{newMail.card.shop}" multiple="true"
value="newMail.shop" optionValueField="uid" optionLabelField="title"
prependOption="Bitte Verkaufsstelle wählen..." /><br />

The list is generated from all shops related to the card.

After sending this form the property $shop from Mail is empty. But why... i
dont understand the problem on this...?!

Thx and regards
Manfred


More information about the TYPO3-project-typo3v4mvc mailing list