Jsonmodel Return Problem

Asked

Viewed 39 times

1

I’m developing an app using Zend Framework 2 and Angular.js.

I have a Rest API module and also use a standard module returning Jsonmodel of more specific things (the problem lives there).

In my module.config.php, I configured my view_manager this way:

'view_manager' => array(
    'display_not_found_reason' => true,
    'display_exceptions'       => true,
    'doctype'                  => 'HTML5',
    'not_found_template'       => 'error/404',
    'exception_template'       => 'error/index',
    'template_map' => array(
        'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
        'portal/index/index' => __DIR__ . '/../view/portal/index/index.phtml',
        'error/404'               => __DIR__ . '/../view/error/404.phtml',
        'error/index'             => __DIR__ . '/../view/error/index.phtml',
    ),
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
    'strategies' => array(
        'ViewJsonStrategy'
    )
),

During a development time, if I (in my controller) did this:

...
return new JsonModel(array('teste'=>true));
...

He would return a JSON like this:

{"teste":true}

Only I don’t know why he started returning like this:

{"children":[],"options":[],"template":"portal-admin\/transportadora\/verifica-cnpj-cadastrado","terminate":true,"variables":{"teste":true},"append":false}

I already looked at the class reference on Zend’s website and I couldn’t find a solution.

Does anyone know how to solve this situation?

Thank you!

1 answer

0


Solved, the problem was in my controller.

I have a Basecontroller in which all other controllers are "extended" from it. The problem was when I created this controller. I extended it from Abstractrestfulcontroller instead of extending from the Abstractactioncontroller class.

After the names were changed, everything worked correctly!

Thank you!

  • Failed to mark this answer as the solution to your question.

  • Thanks! Thanks! Had not done because the stack does not release before 24 hours of question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.