Friday, December 6, 2013

Weird problem with Form Helper and cache

I use cake some years now from v1.2

I will write down a problem I had just to share it with you and find out whether it's a bug or not.

In my app controller in beforeFilter I have:
if (($newarticles = Cache::read('newarticles', 'short')) == null)
    {
      $this->loadModel('Article');
      $this->Article->recursive = -1;

      $newarticles = $this->Article->find('all', array(...some conditions...);
      Cache::write('newarticles', $newarticles, 'short');
    }


that is to show to a widget in my default layout some new articles. I don't want to query the DB all the time so I cache them. 
In another form (users/edit) I load the user model which hasOne UserDetail. UserDetail has a field newarticles.

When I use  
 echo $this->Form->input('UserDetail.newarticles', array(
      'type'  => 'checkbox',
      'label' => 'new articles?',
      'div'   => array('class' => 'checkbox'))) . "\n";

a select box appears with data from $newarticles in AppController. Isn't that a weird behaviour?

thanks a lot

PS: in AppController I renamed $newarticles to $newarticles1 and everything is fine.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: