title: CakePHP Using FilterComponent "Fatal Error: Cannot access empty property"
body: <p>I'm tired. I searched several components and plugins to implement a simple table with filters. CakePHP is a beauty to those who dominate, but for beginners are headaches. I am begginer :S</p>
  
  <p>After trying several with disastrous results, as none works as the authors say that should work.
  I am now using fully FilterCommponent of <a href="http://www.jamesfairhurst.co.uk/posts/view/cakephp_filter_component/" rel="nofollow">James Fairhurst</a>. </p>
  
  <p>I have faith that someone can help. Please!</p>
  
  <p>I get Fatal Error:</p>
  
  <p><em>Error:  Cannot access empty property</em></p>
  
  <p><em>File:  //lib/Cake/View/View.php</em> </p>
  
  <p><em>Line:  843</em></p>
  
  <p><strong>File AppControlller:</strong></p>
  
  <pre><code>&lt;?php
  App::uses('Controller', 'Controller');
  class AppController extends Controller {
  
  public function isAuthorized($user) {
  // Here is where we should verify the role and give access based on role 
  return true;
  }
  var $_Filter = array();
  var $components = array('Session','Filter');
  var $_Form_options_datetime = array();
  
  function beforeFilter() {
  // for index actions
  if($this-&gt;action == 'index') {
      // setup filter component
      $this-&gt;_Filter = $this-&gt;Filter-&gt;process($this);
      $url = $this-&gt;Filter-&gt;url;
      if(empty($url)) {
          $url = '/';
      }
      $this-&gt;set('filter_options',array('url'=&gt;array($url)));
      // setup default datetime filter option
      $this-&gt;_Form_options_datetime = array('type'=&gt;'date','dateFormat'=&gt;'DMY','empty'=&gt;'-','minYear'=&gt;date("Y")-2,'maxYear'=&gt;date("Y"));
      // reset filters
      if(isset($this-&gt;data['reset']) || isset($this-&gt;data['cancel'])) {
              $this-&gt;redirect(array('action'=&gt;'index'));
      }
  }
  }
  
  function process_datetime($fieldname) {
      $selected = null;
      if(isset($this-&gt;params['named'][$fieldname])) {
          $exploded = explode('-',$this-&gt;params['named'][$fieldname]);
          if(!empty($exploded)) {
              $selected = '';
              foreach($exploded as $k=&gt;$e) {
                  if(empty($e)) {
                      $selected .= (($k==0) ? '0000' : '00');
                  } else {
                      $selected .= $e;
                  }
                  if($k!=2) {$selected.='-';}
              }
          }
      }
  return $selected;
  }
  }
  </code></pre>
  
  <p><strong>File ServicesController:</strong></p>
  
  <pre><code>&lt;?php
  App::uses('Component', 'Controller');
  
  App::uses('Sanitize', 'Utility');
  
  
  class ServicesController extends AppController {
  public $helpers = array('Html','Form','Session','Paginator');
  public $components = array('Session','Filter');
  public $name = 'Services';
  
  
  public function index() {
  
  $this-&gt;set('service', array_merge($this-&gt;_Form_options_datetime, array('selected'=&gt;$this-&gt;process_datetime('Service.fecha_reg'))));
  
  $this-&gt;set('service', array_merge($this-&gt;_Form_options_datetime, array('selected'=&gt;$this-&gt;process_datetime('Service.fecha_mod'))));
  
  $this-&gt;Service-&gt;recursive = 0;
  
  $this-&gt;set('service', $this-&gt;paginate(null, $this-&gt;_Filter));
  
  }
  </code></pre>
  
  <p><strong>File index.ctp</strong></p>
  
  <pre><code>&lt;?php echo $this-&gt;$form-&gt;create('Service',array('action'=&gt;'index','id'=&gt;'filters')); ?&gt; //Nuevo codigo
  
  &lt;table&gt;
  &lt;thead&gt;
  &lt;tr&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;Paginator-&gt;sort('id','ID', $filter_options); ?&gt;&lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;Paginator-&gt;sort('nombre', 'Nombre', $filter_options);?&gt;  &lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;Paginator-&gt;sort('precio', 'Precio', $filter_options);?&gt;  &lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;Paginator-&gt;sort('duracion', 'Duración', $filter_options);?&gt;      &lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;Paginator-&gt;sort('fecha_mod', 'Modificado', $filter_options);?&gt;  &lt;/th&gt;
      &lt;th&gt;Acciones&lt;/th&gt;       
      &lt;/tr&gt;
  &lt;tr&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;form-&gt;input('nombre'); ?&gt;&lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;form-&gt;input('precio'); ?&gt;&lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;form-&gt;input('duracion'); ?&gt;&lt;/th&gt;
      &lt;th&gt;&lt;?php echo $this-&gt;form-&gt;input('fecha_mod', $date_options_created); ?&gt;&lt;/th&gt;
      //&lt;th&gt;&lt;?php echo $this-&gt;form-&gt;input('modified', $date_options_modified); ?&gt;&lt;/th&gt;
      &lt;th&gt;
          &lt;button type="submit" name="data[filter]" value="filter"&gt;Filtro&lt;/button&gt;
          &lt;button type="submit" name="data[reset]" value="reset"&gt;Reinicio&lt;/button&gt;
      &lt;/th&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;?php $count=0; ?&gt;
  &lt;?php foreach($services as $service): ?&gt;                
  &lt;?php $count ++;?&gt;
  &lt;?php if($count % 2): echo '&lt;tr&gt;'; else: echo '&lt;tr class="zebra"&gt;' ?&gt;
  &lt;?php endif; ?&gt;
  
      &lt;td&gt;&lt;?php echo $service['Service']['id'] ?&gt;&lt;/td&gt;
  
      &lt;td&gt;&lt;?php echo $this-&gt;Html-&gt;link( $service['Service']['nombre'], array('action'=&gt;'ver', $service['Service']['id']),array('escape' =&gt; false) );?&gt;&lt;/td&gt;
  
      &lt;td&gt;&lt;?php echo $service['Service']['precio'] ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $service['Service']['duracion'] ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $service['Service']['fecha_mod']; ?&gt;&lt;/td&gt;
      &lt;td&gt;
  
      &lt;?php echo $this-&gt;Html-&gt;image('ver-24px.png', array('title' =&gt; 'Ver registro','alt' =&gt; 'Ver registro', 'border' =&gt; '0','url'=&gt;array('action' =&gt; 'ver',$service['Service']['id']))); ?&gt;
      &lt;?php echo $this-&gt;Html-&gt;image('editar-24px.png', array('title' =&gt; 'Editar registro','alt' =&gt; 'Editar registro', 'border' =&gt; '0','url'=&gt;array('action' =&gt; 'editar',$service['Service']['id']))); ?&gt;      
  
      &lt;?php 
      echo $this-&gt;Form-&gt;postLink(
          $this-&gt;Html-&gt;image('/app/img/borrar-24px.png', array(
              'alt' =&gt; 'Borrar registro',
              'title' =&gt; 'Borrar registro', 
              'border' =&gt; '0')),          
              array('action' =&gt; 'eliminar',$service['Service']['id']),
              array('escape' =&gt; false,'confirm' =&gt; '¿Seguro que quieres elminarlo?')); 
      ?&gt;  
  
      &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php endforeach; ?&gt;
  &lt;?php unset($service); ?&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>