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
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
Post a Comment