[TYPO3-mvc] Problem with using an object and a form together in a action

Steffen Roßkamp theconquerer at gmx.de
Sun Jun 3 20:11:34 CEST 2012


Hi list,

I got a problem with including a form in an action viewing another object.

The view action signature in the controller is as follows:

	/**
	 * Highlight view of a product
	 *
	 * @param Tx_xxx_Domain_Model_Product $product = NULL
	 * @param Tx_xxx_Domain_Model_FormObject_InquirySmall $inquirySmall = NULL
	 * @return void
	 * @dontvalidate $product
	 * @dontvalidate $inquirySmall
	 */
	public function showHighlightedAction(Tx_xxx_Domain_Model_Product
$product = NULL, Tx_xxx_Domain_Model_FormObject_InquirySmall
$inquirySmall = NULL) {

...
}

Tx_xxx_Domain_Model_Product is the class of the object shown and
Tx_xxx_Domain_Model_FormObject_InquirySmall is the class of the form object.

The fluid code for the form is:

<f:form controller="Product" action="createInquiry"
object="{inquirySmall}" name="inquirySmall" arguments="{product: product}">

(I actually use fed:form from the fedext extension, but the problem
stays the same with fed and fluid form.)

Then when sending the form I always got the exception

#1251730701: The value must be of type "Tx_xxx_Domain_Model_Product" but
was of type "NULL".

Followed by a list of errors that several properties could not be set.
All properties mentioned are from
Tx_xxx_Domain_Model_FormObject_InquirySmall.

After doing some search and trying several possible solutions I included
all properties from Tx_xxx_Domain_Model_FormObject_InquirySmall also in
Tx_xxx_Domain_Model_Product along with their setters. It is now possible
to send the form and it is correctly validated and createInquiry is also
called successfully if the form is valid.

So long this is therefor working. But it seems kind of strange that I
have to poison my Product class with properties from the InquirySmall to
get this working.

Does anyone know a better solution to this?

Greetings and thanks

Steffen


More information about the TYPO3-project-typo3v4mvc mailing list