callback afterFind

Asked

Viewed 68 times

1

  • Have you tried the one exit() in the afterFind() to see if this passing by there?

  • @Jeferson Assis the exite would be at the end of the method? And it would be like this: exite(); ?

  • I’ve analyzed your code better, you can test the answer below

  • 1

    you have completely changed your question, it is advisable to create a new question when the problem is different from the one quoted in this. Go back to the previous question and create a new one so I can help you.

  • Hello André, I recommend following the guidance of Jeferson and separate your questions in different topics and not change the context of your question mainly in cases where you have already answered it. If your other question is related to this one you can link it to give more context. Enjoy and make a [tour] to know better the functioning of the community.

2 answers

1


Analyzing your code I saw that you use the method query() of the model.

$despesas=$this->Despesa->query("select * from despesas where data_despesa like '%$this->dataDespesa%'");

When you use a custom query, it does not automatically switch to the afterFind()

You can make his call in sequence:

$despesas = $this->Despesa->afterFind($this->Despesa->query("select * from despesas where data_despesa like '%$this->dataDespesa%'"));

As your query is simple there is no need to make a custom query

Just use the method find()

$despesas = $this->Despesa->find('all', array(
    'conditions'=>array(
        'data_despesa like'=>"%{$this->dataDespesa}%"
    )
));

So it will automatically go through all the callbacks.

0

Already solved. The problem is that I was using the same methods to format date and monetary value of beforeSave. beforeSave replaces "/" with "-" and puts it in y, m, d. E replaces "," with "." in monetary value.

To display in the view, you needed to do the opposite: put the date in d, m, y and replace "-" with "/". And in monetary value, replace "." with ",".

Appmodel

http://hastebin.com/amabarotey.php

Model Despesa

http://hastebin.com/ipuyajexux.coffee

controller Expenses

http://hastebin.com/yihuwafiba.coffee

Browser other questions tagged

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