Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Filter naming incorrect in model 13 Feb 2013 22:08 #6737

I have created a Filter for a list Layout and used as a Field a column of a Foreign Key nested in another Foreign Key.
It may sound awkward but I will give you a practical example:

Added filter Combo Box
In the Fields menu I have a Foreign Key called 'booking_id'.
If I expand the Foreign Key it reveals all the columns of it's table, let's call it "Bookings"
The "Bookings" table has a column named "contractor_id" which belongs to the table "Contractors"
I expand the Foreign Key and it reveals all the columns of the "Contractors" table.
One of the column is "name" and I drag this column in the Combo Box filter.

Cook adds an if statement to the corresponding Model in the function prepareQuery.

//WHERE - FILTER : Name
if($this->getState('filter._booking_id_contractor_id'))
$this->addWhere('_booking_id_.contractor_id = '. $this->_db->Quote($this->getState('filter._booking_id_contractor_id')));

The bug is the first '_' in filter._booking_id_contractor_id, right before 'booking'

In the view the naming is correct:
$model->getState("filter.booking_id_contractor_id")

I do not think it will be hard for you to fix this :)

Please Log in or Create an account to join the conversation.

Re: Filter naming incorrect in model 14 Feb 2013 09:04 #6740

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi there,

This is normal cook behaviour... The underscore is prepended to aliased Foreign tables and keys.

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: Filter naming incorrect in model 14 Feb 2013 13:39 #6752

Well, I could see that, but, in this specific circumstance, the naming is incorrect.
I do not want to be rude, but did you even check it out?
This is a glimpse of the model generated by Cook:

//WHERE - FILTER : Name
if ($this->getState('filter._booking_id_contractor_id'))
$this->addWhere('_booking_id_.contractor_id = ' . $this->_db->Quote($this->getState('filter._booking_id_contractor_id')));

//WHERE - FILTER : Location A
if ($this->getState('filter.location_a_id') != null)
$this->addWhere('a.location_a_id = ' . (int) $this->getState('filter.location_a_id'));

//WHERE - FILTER : Location B
if ($this->getState('filter.location_b_id') != null)
$this->addWhere('a.location_b_id = ' . (int) $this->getState('filter.location_b_id'));

//WHERE - FILTER : Driver ID
if ($this->getState('filter.driver_id') != null)
$this->addWhere('a.driver_id = ' . (int) $this->getState('filter.driver_id'));

//WHERE - FILTER : Car ID
if ($this->getState('filter.car_id') != null)
$this->addWhere('a.car_id = ' . (int) $this->getState('filter.car_id'));

//WHERE - FILTER : Status
if ($this->getState('filter.status'))
$this->addWhere('a.status = ' . $this->_db->Quote($this->getState('filter.status')));

//WHERE - FILTER : Booking ID
if ($this->getState('filter.booking_id') != null)
$this->addWhere('a.booking_id = ' . (int) $this->getState('filter.booking_id'));

If you take a look at the code above, NONE of the getState parameters has "filter._", only the first one, which is wrong.
As I previously mentioned, in the view the naming is without "_".
I very much appreciate Cook, more than you imagine, and that is why I want to help you guys get rid of all the tiny bugs that I stumble upon (not so many :))

Please Log in or Create an account to join the conversation.

Re: Filter naming incorrect in model 14 Feb 2013 14:25 #6753

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi there

I didn't look that closely I'm afraid as I'm 'off' today as its half term this week and I'm looking after my daughter.

Could you post the version of cook you're using as well as well as your builder config (JS, form handling etc) and I'll take a proper look at it tomorrow (or tonight if I get chance)

One thing to check, with the field in question - did you drag the child field or the table node?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Last edit: by JoomGuy.

Re: Filter naming incorrect in model 14 Feb 2013 15:31 #6755

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Yes you are right, there is a gremelin here.

But don't worry the filters are 100% rewritted now.
This has been the most long and difficult rewrite.

Actually, filters are not correctly handled. Look at the foreign keys groups ... you are soo limited in 2.0 beta.

With 2.0 is coming a much better work.
By the way, I also introduced JForms in the filters.

Long is the way. I am currently finishing the Bootstrap integration and IUs (sortables, icomoon, ...) because they will be availables as well for components running under 1.6

By the way... I discover the use of the fonts for rendering icon, and I just find it amazing.
Coding is now a piece of cake
The following user(s) said Thank You: BTB300

Please Log in or Create an account to join the conversation.

Re: Filter naming incorrect in model 14 Feb 2013 15:34 #6756

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
By the way, let's call the new coming version 2.5

Because 2.0 is actually the 'beta' of 2.5

Yes... this is official. 2.5 is coming, not anymore 2.0
Coding is now a piece of cake
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Re: Filter naming incorrect in model 14 Feb 2013 15:39 #6757

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hooray for 2.5!!!

Jocelyn, I think you are the coolest dude in the world B)

G
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.071 seconds

Les générateurs de code je les connais presque tous pour les avoir essorés en long en large et en travers ... mais celui ci c'est vraiment un outil formidable de simplicité et d'efficacité !
Marc. (liubov - Forum)

Get Started