• 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: Show an old submission field in form field

Show an old submission field in form field 10 years 4 months ago #29732

  • kareez
  • kareez's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Hi
I have two filed in my form.
one of them is new car kilometer that fill by user. (filed name is new_km)
Second field must shown old submission of new_km. (filed name is old_km)
How can I do it?
Please help me.
Last Edit: 10 years 4 months ago by kareez.
The administrator has disabled public write access.

Show an old submission field in form field 10 years 4 months ago #29741

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try using the following script added within the Default Value area of your "old_km" textbox (including the //<code> tags):
//<code>
$user = JFactory::getUser();
$fId = JRequest::getInt('formId');
$db = JFactory::getDBO();
$db->setQuery("SELECT `FieldValue` FROM #__rsform_submission_values AS rsv LEFT JOIN #__rsform_submissions AS rs ON rsv.SubmissionId=rs.SubmissionId WHERE rs.`Username`='".$user->get('username')."' AND rsv.`FieldName`='new_km' AND rsv.`FormId`='".$fId."' ORDER BY rsv.`SubmissionId` DESC LIMIT 1");
return $db->loadResult();
//</code>

This should take into account the logged in user submitted information. Additionally, you can make the old_km field readonly by adding the following attribute within the Additional Attributes area (edit the field > Attributes > Additional Attributes):

readonly="readonly"

I would also recommend using a script within "Scripts Called on Form Process" area to check when the form submits, if the newly submitted value is not lower than the previously added one:

www.rsjoomla.com/support/documentation/v...602-php-scripts.html

More information on displaying PHP variables when the form is shown can be found here:

www.rsjoomla.com/support/documentation/v...n-form-is-shown.html
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.
  • 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!