[TYPO3-mvc] Fluid: form.select view helper and empty default item
Laurent Foulloy
yolf.typo3 at orange.fr
Fri Aug 6 22:38:21 CEST 2010
Hi all,
I have implemented a solution about which I would like your advice:
1) A class which extends Tx_Extbase_MVC_Controller_Arguments to overload
the method createArgument().
2) A class which extends Tx_Extbase_MVC_Controller_Argument to overload
the method initializeObject(). This class is instanciated in the
previous createArgument() method.
3) A class which extends Tx_Extbase_Property_Mapper to overload the
method transformToObject(). This class is instanciated in the previous
initializeObject() method.
A slight modification is introduced in transformToObject(). The
instruction unset($propertyValue['__identity']); is replaced by
if ($propertyValue['__identity'] == 0) {
$propertyTagsValues =
$this->reflectionService->getPropertyTagsValues($targetType, 'uid');
if (in_array('AllowUidToBeEqualsToZero', $propertyTagsValues['param'])) {
$propertyValue = 0;
}
} else {
unset($propertyValue['__identity']);
}
It uses the reflection service to check if the uid has an
"AllowUidToBeEqualsToZero" param attribute.
4) The method initializeObjects() is overloaded in the controller. It
instanciates the previous class.
To use this feature, in the model associated with the foreign table the
uid variable must be explicitely defined with a @param as follows :
/**
* @var int The uid
* @param AllowUidToBeEqualsToZero
*/
protected $uid;
Regards
Laurent
Laurent Foulloy a écrit :
> Any idea to solve this problem ?
More information about the TYPO3-project-typo3v4mvc
mailing list