Hey guys,
I have already opened a thread which deals with this topic, but I think I have not formulated it well enough.
I have a controller that stores data into a session. It works.
When reading out the session everything is displayed correctly. However, only the first time
The second time I get the Error 500
Form to add:
<f:form action="addItem" objectName="item" controller="Cart" package="NeosCommerce.Cart">
<f:form.hidden property="text" value="This is the text" />
<button type="submit">Add to cart</button>
</f:form>
AddTo Action in my controller:
/**
* @Flow\Scope("session")
*/
class CartController extends ActionController
{
/**
* @var array
*/
protected $items = array();
/**
* @param array $item
* @return void
* @Flow\Session(autoStart = TRUE)
*/
public function addItemAction($item) {
$this->items[] = $item;
$this->redirectToUri('/');
}
//The following action are also here!
}
With this function I get the data:
/**
* @return void
*/
public function miniCartAction() {
$cart = $this->items;
$cartcount = count($cart);
if ($cartcount>0) {
$sum = FALSE;
$sum = intval($sum);
foreach ($cart as $dat) {
$quantity = intval($dat["quantity"]);
$sum += $quantity;
}
$sum = $sum;
} else {
$sum = '0';
}
$this->view->assign('result', $sum);
}
The miniCart Template:
{namespace fusion=Neos\Fusion\ViewHelpers}
{namespace neos=Neos\Neos\ViewHelpers}
<div class="mini-cart">{result}</div>
If I use
return $sum;
instead of
$this->view->assign('result', $sum);
it works perfectly.
As soon as I implement something in Fluid, it does not work anymore.
I hope someone can help me.
Thx,
Pat