[TYPO3-dev] Persisted Model values are not saved anywhere

Xavier Perseguers xavier at typo3.org
Mon Jul 7 09:53:20 CEST 2014


Hi,

> I also adjusted my CategoryController to have a addAction and a
> listAction. The addAction works so far, but the listAction, which is
> called when I call the frontend page with my plugin raises the following
> exception:
> 
> "Oops, an error occurred!
> Found an invalid element type declaration in %s. A type "''" does not
> exist.
> More information regarding this error might be available online."
> 
> It makes no difference, if the listAction looks like
>     public function listAction() {
>         $this->view->assign('categories', 'BLA');
>     }

you are assigning a single string instead of what should be an array

> or like
>     public function listAction() {
>         $categories = $this->categoryRepository->findAll();
>         $this->view->assign('categories', $categories);
>     }
> 
> The template looks like
> 
> <ul>
> <!--f:for each="{categories}" as="cat"-->
>  <li>{categories}</li>
> <!--/f:for-->
> </ul>

Sorry, but what does it mean???

You are commenting out the loop, so with your first example:

$this->view->assign('categories', 'BLA');

you should get

<ul>
  <li>BLA</li>
</ul>

as output. But it won't work in the second example because you cannot
render an "array" coming from Extbase as a string.

Then, your loop should use "cat" and not "categories" inside:

<ul>
  <f:for each="{categories}" as="cat">
    <li>{cat.something-here}</li>
  </f:for>
</ul>

"cat" is a \Vendor\Extension\Domain\Model\Category object, so you need
to show something useful, such as its title:

...
  <li>{cat.title}</li>
...

HTH

-- 
Xavier Perseguers
TYPO3 CMS Team Member

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org




More information about the TYPO3-dev mailing list