The value returned by filters widgets are arrays :

array(
  [text] => "....."
  [is_empty] => true/false
)

And sfValidatorEmail excepts a string.

You can use sfValidatorSchemaFilter class to filter a value :

$validator = new sfValidatorSchemaFilter("my_email_field", new
sfValidatorEmail());

I didn't try this, so I hope it will works ;) Otherwise, the answer is very
similar. Have a look at generated code.

Alexandre

2009/10/20 tirengarfio <[email protected]>

>
> Hi,
>
> I have created the backend for the sfGuardUser module.
>
> Then I have added the Profile fields to the filter using this tutorial
> (in spanish):
>
>
> http://jsangil.blogspot.com/2009/09/modificacion-de-filtros-en-symfony-para.html
>
> Now i have problems when i use "sfValidatorEmail" and
> "sfValidatorFile": after pushing Filter the text "Invalid" appears
> next to the field. It doesnt care if the field is empty or not or if
> the email is written correctly.
>
> Here you have the code:
>
>  <?php
>
> /**
>  * sfGuardUser filter form.
>  *
>  * @package    filters
>  * @subpackage sfGuardUser *
>  * @version    SVN: $Id: sfDoctrineFormFilterTemplate.php 11675
> 2008-09-19 15:21:38Z fabien $
>  */
> class sfGuardUserFormFilter extends PluginsfGuardUserFormFilter
> {
>  public function configure()
>  {
>
>  //Widgets para el filtro de los perfiles
>  $this->widgetSchema['nombre_apellidos'] = new sfWidgetFormFilterInput
> (array(
>      'with_empty' => false
>  ));
>
>
>  $this->widgetSchema['email'] = new sfWidgetFormFilterInput(array(
>      'with_empty' => false
>  ));
>
>  $this->widgetSchema['fotografia'] = new sfWidgetFormFilterInput(array
> (
>      'with_empty' => false
>  ));
>
>  // Validadores
>  $this->validatorSchema['nombre_apellidos'] = new sfValidatorPass
> (array(
>      'required' => false
>  ));
>
>
>  $this->validatorSchema['email'] = new sfValidatorPass(array(
>      'required' => false
>  ));
>
>  $this->validatorSchema['fotografia'] = new sfValidatorPass(array(
>      'required' => false
>  ));
>
>
>
>  }
>
>  public function addNombreApellidosColumnQuery(Doctrine_Query $query,
> $field, $values)
>  {
>    //Se comprueba que no sea nulo el valor del campo del filtro
>    if ($values['text'] != '') {
>      $query->from('sfGuardUser u')
>        ->innerJoin('u.Profile us')
>        ->andWhere("us.nombre_apellidos LIKE ?", '%'.$values
> ['text'].'%');
>    }
>
>  }
>
>
>
> public function addEmailColumnQuery(Doctrine_Query $query, $field,
> $values)
> {
>
>  if ($values['text'] != '') {
>      $query->from('sfGuardUser u')
>        ->innerJoin('u.Profile us')
>        ->andWhere("us.email LIKE ?", '%'.$values['text'].'%');
>  }
>
> }
>
>
> public function addFotografiaColumnQuery(Doctrine_Query $query,
> $field, $values)
> {
>
>  if ($values['text'] != '') {
>      $query->from('sfGuardUser u')
>        ->innerJoin('u.Profile us')
>        ->andWhere("us.fotografia LIKE ?", '%'.$values['text'].'%');
>  }
>
> }
>
>
> public function getFields()
> {
>  return parent::getFields() + array(
>      'nombre_apellidos' => 'Text',
>      'email' => 'Text',
>      'fotografia' => 'Text'
>  );
> }
>
> }
>
> Any idea?
>
> Javi
> >
>


-- 
Alexandre Salomé -- [email protected]

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to