248 Posts
Giuse
7 years ago
9
Topic

Hi, after having discovered a bug in uri->get('type') in Seblod backend (https://github.com/Octopoos/SEBLOD/issues/356), I think I found another problem in Dynamic Cascade: uri->get('id') seems not to work in select dynamic cascade ehn used in the final stage/behavior (it seems to work in the Start stage).

Can you confirm this? 

Thanks

Giuse

Get a VIP membership
1283 Posts
Bucklash
7 years ago
3
Level 1

Hi Guise

Try $uri->getInt('id') 

... based on these...

Select Dynamic SQL query ignores workflow #324

sql-query-inspite-of-workflow

248 Posts
Giuse
7 years ago
2
Level 2

hi and thanks, but unfortunately it's not the reason. getInt() is just like get() but outputting an integer.

A simple case is putting into the end stage of a cascade dynamic

#__content.id <> "$uri->getInt('id')"

to filter out an item, it does not work. If you replace "..." with actual ID, it works.

4229 Posts
Kadministrator
7 years ago
1
Level 3

You should not put integers in quotes, quotes are for strings. ..but it should work regardless of this.

Is this backend?

248 Posts
Giuse
7 years ago
0
Level 4

it should work both with and without quotes for integers. Anyway here it does not work here both in back-end and front-end.

I am getting somehow troubled in using select / select dynamic in a flexible way:

  • there is no way of using field values in the SQL - there is a long thread here proposing a hack https://www.seblod.com/community/forums/fields-plug-ins/select-dynamic-with-fields-variables
  • trying to tune the SQL retrieving the Seblod content type has a bug in backend and (I recently discovered) also a bug in frontend when editing (it works in adding an item) - https://www.seblod.com/community/forums/fields-plug-ins/uri-getvalue-bug-in-saving-select-dynamic
  • now getInt seems not to work in dynamic cascade in End stage.

Are point 2 and 3 being looked at? Any chance of having a feature addition for point 1?

thanks a lot

Giuse

4229 Posts
Kadministrator
7 years ago
4
Level 1

It does not work in any cascade that is retrieved with ajax  - it only works in the first one. Problem is that values from the url are not passed to ajax request.

Workaround (and a better way to do depended selects anyway) is to use normal select dynamic, then filter options using javascript, this is built in function of select2 and similar javascripts.

248 Posts
Giuse
7 years ago
3
Level 2

Hi Klas, I understand that for more flexibility (apart for fixing issue 356) is to use select dynamic (not cascade) and then use javascript to actually set the values, but I have a couple of questions:

  • removing options can be done with plain jQuery, why are you suggesting of using select2 (or chosen or a similar select enhancement plugin)?
  • a select dynamic with no filter means a lot of values retrieved and then removing a lot of them with javascript is somehow "wasteful", can I instead write the select query in the javascript to determine the list of options? I tried with emptying the SQL query of the field and adding values in the javascript but it does not work....

thanks

Giuse

4229 Posts
Kadministrator
7 years ago
2
Level 3

I suggested Select 2 as it is easy to implement, ofcourse it can be done with Jquery or just plain javascript too. In my experience this approach is better as filtering is done instantly compared to slower ajax requests.

248 Posts
Giuse
7 years ago
1
Level 4

Hi Klas, I am not getting the overall proposed solution, I try to explain: I need a select dynamic field that uses values of other fields in the form as WHERE conditions to determine the options of the select field. This is unfortunately not natively supported in Seblod so you are suggesting to use javascript part of the field to tune the option list.

Now, I have read in the forum that only removing options is supported and not adding: no chance of adding? I ask this because if it's like that, the SQL query must be very general (like all items in #__content) to be filtered later on, being a very long (and thus slow) list...

Second problem/question: the Javascript code would filter out many options to implement the WHERE conditions based on other fields values, but to know the list of options to be deleted, I need to query the DB in the JS: I think I need to use an AJAX call again (maybe through select2), no? With which parameters (like which URL)? 

cheers and thanks

Giuse

4229 Posts
Kadministrator
7 years ago
0
Level 5

I made an issue for this as it is an bug

https://github.com/Octopoos/SEBLOD/issues/373

Regarding javascript approach - yes, this is not appropriate when you have long lists.

You can take a look in existing dynamic cascade how it does ajax requests, perhaps simplest solution would be to fix existing one to pass current url variables to the ajax request, this is all that is missing.

Get a Book for SEBLOD