Hi,
I have read a few tutorials and howtos but have not gotten this to
work. I have also looked at the base classes to get an idea on best
practice etc.
I have installed the sfDoctrineGuardPlugin and created a Profile
model, that relates to sfGuardUser. In my admin generated list, I want
to be able to filter the list based on fields in the Profile (namely:
first_name and last_name).
For this I have added some code to the /lib/filter/Doctrine/
sfDoctrineGuardPlugin/sfGuardUserFormFilter.class.php
class sfGuardUserFormFilter extends PluginsfGuardUserFormFilter
{
public function configure()
{
parent::configure();
$this->widgetSchema['first_name'] = new
sfWidgetFormFilterInput(array('with_empty' => false));
$this->widgetSchema['last_name'] = new
sfWidgetFormFilterInput(array('with_empty' => false));
$this->validatorSchema['first_name'] = new
sfValidatorPass(array('required' => false));
$this->validatorSchema['last_name'] = new
sfValidatorPass(array('required' => false));
}
protected function addFirstNameColumnQuery(Doctrine_Query $query,
$field, $values)
{
if (!is_array($values))
{
$values = array($values);
}
if (!count($values))
{
return;
}
$query->leftJoin('r.Profile p')
->andWhereIn('p.first_name = ?', $values);
}
protected function addLastNameColumnQuery(Doctrine_Query $query,
$field, $values)
{
if (!is_array($values))
{
$values = array($values);
}
if (!count($values))
{
return;
}
$query->leftJoin('r.Profile pf')
->addWhere('pf.last_name = ?', $values);
}
}
I have also turned on these filters in the generator.yml and they are
displayed. When I filter for any of these values, I get this error:
"Invalid parameter number: number of bound variables does not match
number of tokens"
which comes from the SELECT ignoring the filter values. This is the
resulting SELECT:
at Doctrine_Connection->execute('SELECT COUNT(*) AS num_results FROM
(SELECT s.id FROM sf_guard_user s LEFT JOIN profiles p ON s.id =
p.sf_guard_user_id LEFT JOIN profiles p2 ON s.id = p2.sf_guard_user_id
WHERE p.first_name = ? IN (?) AND p2.last_name = ? GROUP BY s.id)
dctrn_count_query', array('text' => ''))
This was for a filter where first_name = "Tom" and last_name did not
have anything to filter for. Theoretically, the query should not
include last_name at all. I have checked the $values and they are
correct.
Any ideas how to find out what is going wrong?
juro
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en