121 Posts
deralex
8 years ago
4
Topic

Hi,

I use a dynamic field to concat an article with a user. The user id is passed by url parameter - e.g.: ...?uid=15

My SQL Select:

SELECT id AS value, name AS text FROM #__users WHERE id=$uri->get('did')

The user's name is shown correctly, also the user id is passed correctly as <select value="15".... Filling the form and saving doesn't work, an error 1064 comes up. Manually replacing "$uri->..." by "15" works fine.

What's wrong?

Get a Book for SEBLOD
251 Posts
Viktor Iwan
8 years ago
3
Level 1

are you sure about $uri->get('did') instead $uri->get('uid') ?

121 Posts
deralex
8 years ago
2
Level 2

Sorry... $uri->get('uid') is correct. Damn auto correction...

I've solved it. For everyone else:

If there's a parameter in the url and you save your site / form view, the parameter gets lost. Like:

www.mysite.com/myform?uid=15    ** save ** =>      www.mysite.com/thankyou

In the second url, the parameter sin't still there. When a dynamic field tries to get the parameter that doesn't exist, MySQL gets a request like "SELECT ... WHERE id = AND ...;" which is an error. To avoid this, you have to put in quotes around the call like id='$uri->get("uid")'. The MySQL request is now "SELECT ... WHERE id =' ' AND ...;". This is not an error.

Still the parameter isn't passed to the database, because the saving process seems to try to grab the gone away parameter.

To solve that I use my dynamic field to grab the parameter without saving. Then I add an input field with behavior "When mydynamicfield is filled, take its value". 

Now it finally works. Would be much easier if you could just get the url parameter into live values...

251 Posts
Viktor Iwan
8 years ago
1
Level 3

can you make detail on this "Then I add an input field with behavior "When mydynamicfield is filled, take its value" ? what kind of behavior and how ?

121 Posts
deralex
8 years ago
0
Level 4

"Ist ausgefüllt mit" = "filled with"

"user_name_dyn" = The dynamic field

"Benutzer Name dyn..." = The dynamic field

"Ist ausgefüllt" = "Is filled"

Get a Book for SEBLOD