127 Posts
Cappu
6 years ago
Topic

Hi,

I created a Seblod app in the Joomla backend.

From a list I do want to access a Form and pass over some custom variables (which I need in a dynamic field). - For some reasons I do get errors like this if I hit "Save", "Save and New" or "Close":

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

It is possible to hit "Save and Close". - Seems that the form buttons won't take over the custom variables - and I cannot figure out how to configure the form popup in the List correctly.

Screenshot:

https://monosnap.com/file/xoUXw99kPiWVQkpCNpA62n2Srom3IB

What am I missing?

Any ideas?

Kind regards

Get a Book for SEBLOD
4229 Posts
Kadministrator
6 years ago
5
Level 1

It is not exactly clear what you are trying to do, but you can't use $cck->get in the form, only on the lists and in the content view

127 Posts
Cappu
6 years ago
0
Level 2

Hi Klas,

Thanks for your response.

Well, I'll made some screenshots with annotations...

1. In the List under 2 I try to configure a Link to the form ... here:

https://monosnap.com/file/CzufG3e0GmmjlXiU8nKltzFjdzNZIa

2. If I click on the + to configure this link, the configuration popup opens ... like on this screenshot. There I define some Variables:

https://monosnap.com/file/geSDeaigh8mqUTAlIS7MdrTySLwbl0#

3. The parameters I pass to the form works all right. They are in the URL of the Form and I can read them into my dynamic fields. Here a screenshot from Number 2 of my Form type:

https://monosnap.com/file/iS7bgEZi7opjnWtBR7aD2WuSB3FxK5#

Works fine so far. - 

4. But if I use this form and hit Save or Close and error occurs on Redirect. The reason seem to be, that after updating the database the variables should get passed to the redirect URL, too. This is not the case. - How can I do this?

...Hope all this makes sense.

Thanks for any hint.

Kind regards

127 Posts
Cappu
6 years ago
3
Level 2

Hi Klas,

maybe the problem has its root somewhere else.

It's in one of Select Dynamic fields where I do this:

SELECT ....

FROM ....

WHERE .... AND b.er_ort_land = $uri->get('er_hotel_land');

At better solution would be:

AND b.er_ort_land = $fields['er_hotel_land'];

With this solution I would not have the need to pass any variables through the url. - Everything would work out ot the box.
But according to this thread, this seems not to be possible:

https://www.seblod.com/community/forums/fields-plug-ins/select-dynamic-with-fields-variables

Too bad. :-( 

Any plans to add this (rather basic and really useful) functionality to the Select Dynamic field in the near future?

Thanks!

4229 Posts
Kadministrator
6 years ago
2
Level 3

This is not possible as form fields only have values after the form is saved, before values exist only on the client side, so you need to use client side-javascript based solutions to pass values between the fields. This is done using computation rules and/or conditionals.

For your specific need you can use Select dynamic cascade where options of the second (and optionally third) cascade are retrieved using  ajax

127 Posts
Cappu
6 years ago
1
Level 4

Hi Klas,

Thank you very much for your hints.

"...This is not possible as form fields only have values after the form is saved..."

But in my case the values are there BEFORE the form is created. They are passed via GET/POST. I want to use these values in severeal dynamic fields which then calculates there option fields on the server side depending on these values before the form is sent to the browser.  - So it is not about client side data manipulation.

In my eyes, with the dynamic field it should be possible to read in existing data from the URL or from other fields (or it should be possible to do some calculations, like date/time stuff) and use it right in the SQL statement - "before" the field values are calculated.

How else I could solve my use case: Select a one or more lists of cities (dynmic fields) depending on a given country I do pass through the URL?


4229 Posts
Kadministrator
6 years ago
0
Level 5

As I wrote, this can't be done via $cck->get. To get values from url to the field you can use URL variable live value ad to use it on select dynamic you can use $uri->get (e.g. $uri->getValue('id') )

127 Posts
Cappu
6 years ago
0
Level 1

Hello Klas,

Thanks for your help. Finally I could figure it out:

Here an example of the Dynamic Select Field SQL-Statement with URL-parameter I use in the Form Type:

SELECT a.id AS value, a.title AS text FROM #__content AS a
INNER JOIN #__cck_store_form_xxxxxx AS b ON (b.id=a.id)
WHERE a.catid = 11
AND a.state = 1
AND b.myparamfield = $uri->get('myparam');

The value of myparam is another dynamic select field in the Search section of a List & Search, from which the Admin User is entering the Form & Content. There parameter is sent under List -> Nr. 2 -> Link select Form and open the Popup by clicking on the +-symbol next to "Form". - There in the field "Custom variables" add:

myparam=$cck->getValue('myparam')

After doing all this I noticed that the Save Button did not work any longer - as I described in my first post of this thread. 

I added a Seblod Button Free which points to the form and which I added the the parameter, similar to List -> Nr. 2 -> Link.

Hope all this makes sense and is of help for someone.

Get a Book for SEBLOD