php - sonataadmin bundle FILTERING FIELDS AND CASE SENSITIVITY Not working . No attached service to type named `doctrine_phpcr_string` -


i try create case insensitive filtering using sonataadmin bundle , symfony 2 error.

"symfony/symfony": "2.6.*" "sonata-project/admin-bundle": "^2.3", 

here adminclass

protected function configuredatagridfilters(datagridmapper $datagridmapper) {     $datagridmapper         ->add('name', 'doctrine_phpcr_string', array(             'compare_case_insensitiv' => false         ))      ; } 

here documentation

https://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/reference/filter_field_definition.html#filtering-fields-and-case-sensitivity

here error

no attached service type named `doctrine_phpcr_string` 

here solution :)

  protected function configuredatagridfilters(datagridmapper $datagridmapper)     {         $datagridmapper             ->add('name', 'doctrine_orm_callback',                 array('callback'   => array($this, 'yourfunction'),                     'field_type' => 'search'),                 null,                 array('pattern' => '^[a-za-z0-9]{1,12}$')             );      }      public function yourfunction($querybuilder, $alias, $field, $value)     {         if (!$value['value']) {             return;         }          $querybuilder             ->andwhere("lower(u.name) lower(:field)")             ->setparameter('field', "%{$value['value']}%");          return true;     } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -