• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to set field value from GET?

How to set field value from GET? 2 years 8 months ago #42209

Hello
I need to automatically set form field with value passed by url.
For example: user clicks link .....?var1=sometext
and form displays and one of fields has already value "sometext' form var1.
How can i do it?
The administrator has disabled public write access.

How to set field value from GET? 2 years 8 months ago #42216

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.

How to set field value from GET? 1 year 4 months ago #43167

Documentation is correct but not complete.

You can use a PHP script in default value to retrieve info from a database (see also example 4 in www.rsjoomla.com/support/documentation/r...n-form-is-shown.html). But how to use the passed parameter value in this query?
The administrator has disabled public write access.

How to set field value from GET? 1 year 4 months ago #43168

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
Ok, first pass the value in the url such as 'www.mywebsite.com/index.php?option=com_rsform&formId=2&form[name_of_field]=value

in the destination form if the field name is the same in both forms it will contain the value you passed in the url. If the destination form field has a diffeent name you will need to get the value into it. Use 'php scripts - pre-processing and enter something like this where value form 2 = value form 1
$val['membership_number'] = $val['member-ID']
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
Last Edit: 1 year 4 months ago by iceferret.
The administrator has disabled public write access.

How to set field value from GET? 1 year 4 months ago #43169

I think I didn't explain very well my problem.

Passing a parameter from one form to another works fine if you just have to put that value in a field. But what I want to do, is use this parameter as a key for a query to get another fields default value.

//<code>
$db = JFactory::getDbo();
$db->setQuery("SELECT `column_name` FROM `#__table_name` WHERE `column_name`='value' LIMIT 1");
return $db->loadResult();
//</code>

in this example: how to achieve that "value' becomes the passed parameter?
Last Edit: 1 year 4 months ago by willy.wolters.
The administrator has disabled public write access.

How to set field value from GET? 1 year 4 months ago #43170

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
assign the value to a variable and use that in your query
$mem_num = $val['membership_number'];
 
// Do the db stuff and select all records from the user profile table where key begins with our variable
 
$query->select
->select('m.title')
$query->from($db->quoteName('#__user_profiles'));
$query->where($db->quoteName('profile_key') . " = " . $db->quote($mem_num);
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
The following user(s) said Thank You: willy.wolters
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!