Correction, the method name needs to look like this:

public function addXXXColumnCriteria, where XXX is your field name in
camelcase.

for example, I have a custom filter with the field "coupon", and the
corresponding method looks like:

public function addCouponColumnCriteria(Criteria $criteria, $field,
$value)
  {
    $criteria -> addJoin(CustomerPeer::ID, WebsitePeer::CUSTOMER_ID);
    $criteria -> addJoin(CouponToWebsiteLinkPeer::WEBSITE_ID,
WebsitePeer::ID);
    $criteria -> addJoin(CouponToWebsiteLinkPeer::COUPON_ID,
CouponPeer::ID);
    $criteria -> add(CouponPeer::CODE, $value);
  }

Daniel

On May 1, 5:03 pm, Richtermeister <nex...@gmail.com> wrote:
> Hey there,
>
> ok, I think I'm following you.
> Here's how to go about it:
>
> First, if you're trying to filter on a real date or timestamp column,
> then all the work is already done for you.
> For example, the created_at/updated_at columns would automatically
> cause the filter field that you describe to be created in the filter
> form classes.
>
> So, the only case that you'd have to manually create these fields, is
> that you're not just filtering on one date field, but on a combination
> of different fields..
>
> Either way, the easiest way for you to see how things work is by
> adding a created_at column, regenerating the model/forms and looking
> at the code it generates. You'll find that it uses the
> sfWidgetFormFilterDate widget, which wraps a start-date and an end-
> date field.
>
> So much for displaying the fields (you don't need to use a custom
> partial in the admin generator to display those, the form render shows
> them automatically).
>
> As for building the query, the admin generator calls a "buildCriteria"
> method on the form filter class, and that calls a method for every
> field of the form, so all the query building happens inside the filter
> class. If you add a custom field (as it seems your planning to do),
> you also have to customize the query building by adding a method like
> this:
>
> public function addMyCustomFieldCriteria(Criteria $criteria, $field,
> $value)
> {
>   //manipulate criteria based on the $value variable..
>   //this can include whatever joins / filterings / custom-logic you
> need..
>
> }
>
> depending on how you call your field, the method name needs to match.
> And that's it.. Look more at the generated form filter classes to
> really see what's going on.
>
> Oh, and you always want to customize the regular form filter classes,
> not the Basexxxx classes, as these get overridden whenever you
> regenerate the model.
>
> Does this help?
> Daniel
>
> On Apr 30, 3:22 pm, fRAnKEnSTEin <shirkav...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > thank you for your answer. Ok i have a module in my backend called
> > "price". For this module i need to add a custom filter this is: i need
> > to add to dates, and make a quey based on the dates selected by the
> > user. So by now as i said before i just configure the generator.yml of
> > the "price" module, to show the partial that holds all the html i
> > need(ie the 2 datapickers) in the view of the prices module.
>
> > //app/backend/modules/price/config/generator.yml
> > ...
> > filter:
> >         display: [ _state ]
> > ...
>
> > So when i se my browser to enter into the price module i can see the
> > filter section with thi inputs, where the user can enter the dates(for
> > now they are just 2 simple text inputs) and the "filter" button. Now
> > when the user enters the 2 dates and hit the "filter" button i need to
> > take those 2 inputs and create a custom query(the query is in my first
> > post), but i dont now where i have to create this query...i mean in
> > wich file, maybe in "PriceFormFilter.class.php" or in
> > "BasePriceFormFilter.class.php" or where else? i dont now if i need to
> > overwrite a\ certain function in dome certain class....or if i need to
> > create a normal function and then call it from some special where....
> > that's why i need to do.
>
> > So in few words: i have a price modulo in my backend, i need to show
> > up two inputs in the filtering section of the module, when the user
> > hit the filter button i need to take the values entered in the inputs
> > and execute a custom query so the results will be reflected in the
> > list action or something.
>
> > Any example, ideas? (need more details..just tell me)
>
> > Cheers
>
> > --
> > 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 
> > 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 
> 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

Reply via email to