• 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: Pre-filling a multi field

Pre-filling a multi field 1 day 10 hours ago #44030

I have a form with a multi field that determines the price. The choice is based on age of the signed in user and the current date. I want the php code to select the appropriate price. Having selected the choice, I want to make the proper choice be checked and only it is available to the user. In my code shown below, I continually get the message
Cannot use object of type stdClass as array. It is distinctly from this line of code :
foreach ($form as $option) {
$optionArray = (array) $option; }
var_dump tells me $form is a stdClass - How can I loop through the options within the multi_field [pass_type] to pre-select the one I want.? I have 2 versions of the code - both give the error on the initial foreach.
code1:
foreach ($form as $option) {
$optionArray = (array) $option;

if (isset($optionArray) && trim($optionArray) === $choice) {
$optionArray = 1;
echo 'we found ' . $optionArray('text');
$filtered[] = $optionArray;
$matched = true;
break;
}
}
code2:
foreach ($form as $option) {
if ($option->text === $desiredLabel ) {
$form = [
'0' => [
'value' => $option,
'text' => $option,
'amount' => $option,
'tax' => $option,
'checked' => 1
]
];
break;
}
}
I would really appreciate any help or suggestions. Although I have an account with rsJoomla they seem to feel this is custom code!
The administrator has disabled public write access.

Pre-filling a multi field 15 hours 28 minutes ago #44032

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 251
  • Thank you received: 66
Use JavaScript, I have a membership form where we have rates for UK, Europe , and Rest of the world. With Javascript you can use the country the user has enterd to 'grey out' the UK and Europe member rates leaving the correct optons available. That seems similar to what you are trying to achieve. You can see it in action at this site, just change the country and watch the membership rates
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: lmguttormson
  • 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!