[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-06 Thread fRAnKEnSTEin
Hi there,

Thank you very much for your help:

...that is why some filter inputs (like the date filter field for example) 
have 2 fields with the same name...

Nice piece of info!. Ok you suggested me that i can take a look at the
auto-generated forms. I have searched in cache folder for the auto-
generated code, but i can not find the forms code that you suggested
me to read. I have searched in the next folders:

in cache folder:

myModule/actions
myModule/lib
myModule/Templates

and in these other folders too:

mySite/lib/filter
mySite/lib/form

And nothing. I need to find the auto-generated code to see how they
created the widget with the same name etc etc.

Can you tell me where i have to find these auto-generated forms.

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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-04 Thread Tom Ptacnik
Do you really need all the values together? Can't you just create a
few addXXXColumnQuery methods and create a query in parts?

Example of my filter where I added the choice:


class CommentFormFilter extends BaseCommentFormFilter
{
  public function configure()
  {
$this-widgetSchema['cmtext'] = new
sfWidgetFormFilterInput(array('template' = '%input% %empty_checkbox%
%empty_label%'));

$this-widgetSchema['cmpublish'] = new sfWidgetFormChoice(array(
'choices' = CommentPublish::getArray(),
'expanded' = true,
'multiple' = true
));

$this-validatorSchema['cmpublish'] = new sfValidatorChoice(array(
'required' = false,
'choices' = array_keys(CommentPublish::getArray()),
'multiple' = true
));
  }

public function addCmpublishColumnQuery($query, $field, $value)
{
$fieldName = $this-getFieldName($field);

if (!empty($value))
{
$query-andWhereIn(sprintf('%s.%s', 
$query-getRootAlias(),
$fieldName), $value);
}
}
}


On 3 kvě, 05:19, fRAnKEnSTEin shirkav...@gmail.com wrote:
 hi There,

 i do not need to make a join just a select * from where
 myCriteriaHere the criteria is:

    (initial_date =  myCustomInput1 and final_date =
 myCustomInput1 )
    or
    (final_date =  myCustomInput2 and initial_date =
 myCustomInput2 )
    or
    (initial_date = myCustomInput1 and final_date = myCustomInput2)

 As yo can see i need to acces 2 values for create the query, following
 your example supose i have 2 coupon fields, and into my
 addCouponColumnCriteria method, i will need access to my coupon value
 and my coupon2 value, but as long a i can see, if i use the method
 addCouponColumnCriteria, i only have acces to the coupon field, that
 its value comes into the $value parameter.

 So how can i create a method addGENERICColumnCriteria, where i can
 have access to all the fields so i can create my complex criteria
 using all the values that i need? or is there any way to acces the
 values of the other fields inside addCouponColumnCriteria method?

 Do you got me? BTW i do not have any idea of what these things you
 used means: CustomerPeer::ID, WebsitePeer::CUSTOMER_ID

 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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-04 Thread fRAnKEnSTEin
Hi,

As i see..i think i can not add few addXXXColumnQuery methods and
create a query in parts. I tell you why. I have 2 custom inputs, so
if i create 2 addXXXColumnQuery methods, ill end with something like
this:

public function addMyCustomInput1ColumnQuery($query, $field, $value)
{
}

public function addMyCustomInput2ColumnQuery($query, $field, $value)
{
}

Now the query i need to create is this one:

$auery = Select * table
  where
  (initial_date =  myCustomInput1 and final_date =
myCustomInput1 )(*)
  or
  (final_date =  myCustomInput2 and initial_date =
myCustomInput2 )(**)
  or
  (initial_date = myCustomInput1 and final_date =
myCustomInput2)  (***)

First of all, as you see i need to create 3 conditions(marked with
(*), (**) and (***) ) and following your approach i only got 2
methods(one for each field that i am using, these are:myCustomInput1
and myCustomInput2),

Second each condition uses both fields for creating the query, so if i
use the method as you suggest:

public function addMyCustomInput1ColumnQuery($query, $field, $value)
{
  //HERE I GET THE MyCustomInput1 value
  $field = $this-getFieldName($field);

  //HERE I USE THE $field VARIABLE TO MAKE THE FIRST
CONDITION..BUT ALSO NEED TO GET THE myCustomInput1 VALUE TOO...AND
INSIDE THIS METHOD I DONT KNOW HOW, I
  //NEED SOMTHING LIKE
  $query-andWhere(initial_date =  $fieldName and final_date =
myCustomInput1 )
}

and as you can see even i i create the first condition comehow, even i
have to separece eachone (*),(**) and (***) with OR. So, please note
the query i need to create, i have 2 OR and 3 ANDS, each AND uses
myCustomInput1 and myCustomInput1 for creating the differents
conditions...

This is why i can not use just the addXXXColumnQuery and create the
query by parts...

Am i right?

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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-02 Thread fRAnKEnSTEin
hi There,

i do not need to make a join just a select * from where
myCriteriaHere the criteria is:


   (initial_date =  myCustomInput1 and final_date =
myCustomInput1 )
   or
   (final_date =  myCustomInput2 and initial_date =
myCustomInput2 )
   or
   (initial_date = myCustomInput1 and final_date = myCustomInput2)

As yo can see i need to acces 2 values for create the query, following
your example supose i have 2 coupon fields, and into my
addCouponColumnCriteria method, i will need access to my coupon value
and my coupon2 value, but as long a i can see, if i use the method
addCouponColumnCriteria, i only have acces to the coupon field, that
its value comes into the $value parameter.

So how can i create a method addGENERICColumnCriteria, where i can
have access to all the fields so i can create my complex criteria
using all the values that i need? or is there any way to acces the
values of the other fields inside addCouponColumnCriteria method?

Do you got me? BTW i do not have any idea of what these things you
used means: CustomerPeer::ID, WebsitePeer::CUSTOMER_ID

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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-01 Thread Richtermeister
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 Base 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 classor 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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-05-01 Thread Richtermeister
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 Base 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 classor 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 

[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-04-30 Thread Richtermeister
Hey there,

in sf1.2+, the admin filtering is handled via filter form classes, so
all customization and filter logic should go in there.
The form is not only responsible for displaying and validating the
widgets, but since it extends sfFilterForm it also contains methods
that build a query / criteria object for you.
So, you can literally handle all, even the most complex, filtering
operations completely within a filter form class.

Does that help? If not, please specify what you're trying to do and
I'll try to help better.

Daniel




On Apr 30, 12:58 pm, fRAnKEnSTEin shirkav...@gmail.com wrote:
 Hi,

 I need to create a custom complex filtering criteria in the admin
 generator backend. In previeus version of symfony(ie 1.1) this can
 done by overwriting the addFiltersCriteria, method but in symfony
 1.4 dont now how to achive this?

 For now, i have modfied my module's generator.yml file to use a
 partial for rendering the filtering section in the view as follows:
 ...
 filter:
         display: [ _state ]
 ...

 In the partial(_state) i have the next html:

 input id='myCustomInput1' name=myCustomInput1/
 input id='myCustomInput2' name=myCustomInput2/

 Now i want to create my custom criteria using the  inputs defined in
 the _state partial above, like so:

 (initial_date =  myCustomInput1 and final_date = myCustomInput1 )
 or
 (final_date =  myCustomInput2 and initial_date = myCustomInput2 )
 or
 (initial_date = myCustomInput1 and final_date = myCustomInput2)

 1- Where do i have to add my custom query?
 2- How can i access the myCustomInput1 inputs defined in the partial
 to create the query i need?

 PD: I have generate the admin backend using this comand: php symfony
 generate:app backend

 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 at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How overwrite addFiltersCriteria in symfony 1.4?

2010-04-30 Thread fRAnKEnSTEin
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 classor 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 at
http://groups.google.com/group/symfony-users?hl=en