• 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: Limit entry to specific info

Limit entry to specific info 8 years 2 months ago #36483

  • ttnae
  • ttnae's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 1
Hello, I am using RSFORMS for our trucking company maintenance form. Drivers go into the form and enter their truck number, trailer number and other info.
How can limit the info that these fields to only accept specific entries like 1366, 1367, 1368 & 1369? I do not want to use the drop-down as it is prone to driver selecting the wrong item on their cell phone screen.

Is there some code that I can enter into the attributes section that will limit this to correct entries only?

Thank you
The administrator has disabled public write access.

Limit entry to specific info 8 years 2 months ago #36488

  • qubertman
  • qubertman's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 5
Under Form Properties > PHP Scripts > Script called on form process, add the following and replace 2 instances of REPLACENAME with the name of the field being checked:
$validCodes = array('1366', '1367', '1368', '1369');
if (!in_array($_POST['form']['REPLACENAME'], $validCodes)) {
  $invalid[] = RSFormProHelper::getComponentId("REPLACENAME");
}
The administrator has disabled public write access.
The following user(s) said Thank You: ttnae

Limit entry to specific info 8 years 2 months ago #36513

  • ttnae
  • ttnae's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 1
I have run into another small problem that I do not know how to fix. I entered the first one, which is for our truck numbers but there is also one for trailer numbers.
There are confitional field settings which only show truck number when "truck" is selected and trailer numbers when "trailer" is selected.

Is it possible to run this script for both or multiple fields in the same form?
$validCodes = array('9679', '9680', '8774', '8775', '9264', '9265', '1366', '1367');
if (!in_array($_POST, $validCodes)) {
$invalid[] = RSFormProHelper::getComponentId("trucknum");
}

$validCodes = array('46463', '51338', '54373', '61955', '61956', '61958', '61959', '61960');
if (!in_array($_POST, $validCodes)) {
$invalid[] = RSFormProHelper::getComponentId("trailer");
}
The administrator has disabled public write access.

Limit entry to specific info 8 years 2 months ago #36524

  • qubertman
  • qubertman's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 5
You will have to change TYPE to the name of the field that is used to select truck or trailer.
$validCodes = array('9679', '9680', '8774', '8775', '9264', '9265', '1366', '1367');
if ($_POST['form']['TYPE'] == 'truck' && !in_array($_POST['form']['trucknum'], $validCodes)) {
  $invalid[] = RSFormProHelper::getComponentId("trucknum");
}
 
$validCodes = array('46463', '51338', '54373', '61955', '61956', '61958', '61959', '61960');
if ($_POST['form']['TYPE'] == 'trailer' && !in_array($_POST['form']['trailernum'], $validCodes)) {
  $invalid[] = RSFormProHelper::getComponentId("trailernum");
}
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!