[TYPO3-mvc] Tx_Extbase_MVC_Exception_InfiniteLoop
Claus Due
claus at wildside.dk
Wed Jan 4 01:28:54 CET 2012
Hi Mark,
After checking the Fluid source code f:form.checkbox expects "checked" to be a boolean - however, it should work without it because object accessor mode is enabled:
(from checkboxviewhelper source)
if ($checked === NULL && $this->isObjectAccessorMode()) {
$propertyValue = $this->getPropertyValue();
if (is_bool($propertyValue)) {
$checked = $propertyValue === (boolean)$valueAttribute;
} elseif (is_array($propertyValue)) {
$checked = in_array($valueAttribute, $propertyValue);
$nameAttribute .= '[]';
} else {
throw new Tx_Fluid_Core_ViewHelper_Exception('Checkbox viewhelpers can only be bound to properties of type boolean or array. Property "' . $this->arguments['property'] . '" is of type "' . (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)) . '".' , 1248261038);
}
}
First, you should remove the "checked" attribute and let object accessor mode handle things. I'm hoping this works with your current propertymapper/validation setup.
Next:
$args = $this->request->getArguments();
$paymentType = $args['order']['paymentType'];
...is probably unnecessary, since you should have this as $order->getPaymentType() already.
But code looks better now, a good tip is to keep just one parameter for your create/new/update/delete methods - this makes it easier to find problems :)
Cheers,
Claus
On Jan 4, 2012, at 12:20 AM, Mark Kuiphuis wrote:
> On 4/01/12 2:57 AM, Claus Due wrote:
>> On Jan 3, 2012, at 5:51 PM, Marc Bastian Heinrichs wrote:
>>
>>> Tx_TravelPrograms_Domain_Model_Order has a property program.
>>
>> Then I suppose both fields, name and property, should be present - or {program: program.uid} in should be put in arguments attribute on f:form.
>>
>> Cheers,
>> Claus
>
> Hi all,
>
> First of all I would like to thank everyone who has contributed and help me a lot in getting the extension closer to a finish :-) I couldn't have done it without you...
>
> I also would like to apologize for the early (or late) replies to your answers. A couple of years ago that would not have been the case when I was still living in Europe, but 9 timezones further to the east all causes this....(it's great here though :D)
>
> Anyway back to the "challenge"...
>
> Over the hours after I sent my last reply I changed the createAction to look like this:
>
> /*
> * @param Tx_TravelPrograms_Domain_Model_Order $order A fresh order object which has not been added to the repository yet
> * @return void
> */
> public function createAction(Tx_TravelPrograms_Domain_Model_Order $order) {
> $program = $this->programRepository->findByUid($order->getProgram());
> $order->setPrice($program->getPrice());
> $this->orderRepository->add($order);
>
> $persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
> /* @var $persistenceManager Tx_Extbase_Persistence_Manager */
> $persistenceManager->persistAll();
>
> $args = $this->request->getArguments();
> $paymentType = $args['order']['paymentType'];
>
> switch($paymentType) {
> case 1: {
> $this->forward('ideal', NULL, NULL, array('order' => $order));
> break;
> }
> default: {
> $this->forward('transfer', NULL, NULL, array('order' => $order));
> break;
> }
> }
> }
>
> So, in the first line I do retrieve the $program object which I need to store the order. (This order is a simple order as in that you can only order one product at a time....the product is a "travel program", that's why I added the program uid and program price to the order (price for historic reasons if the price of the program is going to be changed in the future).
>
> Saving the form when there are no validation errors works fine....(for now and I'll try not to break things :D)...
>
> Getting the checkboxes and radio buttons to prefill when validation fails however not.....
>
> Cheers, Mark
> _______________________________________________
> 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