Re: [symfony-users] Re: Filtering a list from the action
I finally get it works with this: $this-filter = new BirthdayFormFilter(array('name'=array('text'='Peter'))); Javi On 02/16/2010 05:35 PM, Javier Garcia wrote: I give you more code: I have this code below in the index template. The filter form (without Peter as default value, of course..) and Peter are showed. ?php use_helper('Form'); ?. ?php echo form_tag('birthday/filtrar') ? ?php echo $filter; ? div?php echo submit_tag('Filter') ?/div /form ?php echo $filter-getDefault('name'); ? And this is the action: class birthdayActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this-filter = new BirthdayFormFilter(); $this-filter-setDefault('name', 'Peter'); } Javi On 02/15/2010 07:28 PM, Florian wrote: 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 Brunc.b...@nooveo.fr 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 : symfony-users@googlegroups.com [mailto:symfony-us...@googlegroups.com] De la part de Javier Garcia Envoyé : lundi 15 février 2010 14:23 À : symfony-users@googlegroups.com 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-mergehttp://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 symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/symfony-users?hl=en. -- 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 symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: Filtering a list from the action
On 02/16/2010 04:19 PM, Florian wrote: What is the error? Have you cleared your navigation history/cache ? ( firefox seems to keep the selected values... ) Yes, i cleared it but the default value is not showed.. There isn't any error. -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Re: Filtering a list from the action
On 02/16/2010 04:26 PM, Tom Ptacnik wrote: Or you need to set this in the action? Yes, i need to set this in the action. -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Re: Filtering a list from the action
I give you more code: I have this code below in the index template. The filter form (without Peter as default value, of course..) and Peter are showed. ?php use_helper('Form'); ?. ?php echo form_tag('birthday/filtrar') ? ?php echo $filter; ? div?php echo submit_tag('Filter') ?/div /form ?php echo $filter-getDefault('name'); ? And this is the action: class birthdayActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this-filter = new BirthdayFormFilter(); $this-filter-setDefault('name', 'Peter'); } Javi On 02/15/2010 07:28 PM, Florian wrote: 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 Brunc.b...@nooveo.fr 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 : symfony-users@googlegroups.com [mailto:symfony-us...@googlegroups.com] De la part de Javier Garcia Envoyé : lundi 15 février 2010 14:23 À : symfony-users@googlegroups.com 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-mergehttp://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 symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. 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 symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.