Hello,
To my mind, you should use this method:
{{{
$this->filter->setDefault('name', 'Peter');
}}}
It's more correct, because semantically, you want set a default value
to your form, not to your model object!
But if you want to set use the contructor of the sfFormFilter >
BaseForm > sfFormSymfony, see it's signature:
public function __construct($defaults = array(), $options = array(),
$CSRFSecret = null);
So you can pass an *array* of default values as first argument.
It's different from your Birthday form, which inherits from
sfFormDoctrine, see it's signature:
public function __construct($object = null, $options = array(),
$CSRFSecret = null)
here, the first argument has to be null OR a Doctrine ActiveRecord /
Object.
Hope it helps!
/Florian
On 15 fév, 16:49, "NOOVEO - Christophe Brun" <[email protected]> wrote:
> I am working on the 'list' view of a module.
> The filtered list is displayed via a call to the executeFilter() method, as
> usual.
>
> Now, I create a route and the appropriate method myModuleActions :
>
> public function executeUseMyFilter(sfWebRequest $request) {
> $id = $this->getRoute()->getObject()->getId();
>
> // force the filter value to myotherobj_id = #the id in the route //
> // ?????????????????? //
>
> return $this->executeFilter($request);
>
> }
>
> But I can't find the way to modify the filters and to force the
> exceuteFilter() method to display only the list of objects having
> myotherobj_id = $id.
>
> ________________________________
>
> De : [email protected] [mailto:[email protected]]
> De la part de Javier Garcia
> Envoyé : lundi 15 février 2010 14:23
> À : [email protected]
> Objet : [symfony-users] Trying to give a default value to a filter form
>
> Hi,
>
> im trying to give a default value to a field of a filter.
>
> I have no problems giving a default value to a form this way:
>
> $m = new Birthday();
> $m->setName('Peter');
> $this->filter = new BirthdayForm($m);
>
> But when i try this:
>
> $m = new Birthday();
> $m->setName('Peter');
> $this->filter = new BirthdayFormFilter($m);
>
> this error appears:
>
> Warning: array_merge() [function.array-merge
> <http://rs.localhost/frontend_dev.php/function.array-merge> ]: Argument #2 is
> not an array in
> /opt/lampp/htdocs/rs/lib/vendor/symfony/lib/form/sfForm.class.php on line 1023
>
> Any idea?
>
> Javi
>
> --
> 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
> athttp://groups.google.com/group/symfony-users?hl=en.
--
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.