This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 4
Targeting 'Drop Down' in helper-functions.php for replacement. How?
Started 9 years ago by MvdL79 | 9 posts |
-
Hi Yuniar / other staff members,
Quick question; I am still using the code Yuniar once had given me to replace targeted 'Multiple Choice' fields, so it would replace them with custom, defined, values. Like shown below:
if($data['element_type'] == 'radio' && $target_is_admin === true){ if($form_id == xxxxx){ if($data['element_id'] == xx){ if($data['value'] == "Option number 1"){ $entry_details[$i]['value'] .= " (Product code: 66005)"; }elseif($data['value'] == "Option number 2"){ $entry_details[$i]['value'] .= " (Product code: 66006)"; }elseif($data['value'] == "Option number 3"){ $entry_details[$i]['value'] .= " (Product code: 66007)"; }elseif($data['value'] == "Option number 4"){ $entry_details[$i]['value'] .= " (Product code: 66008)"; } } } }
How would I target a 'Drop Down' field in this case?
Because there is no type for this. So probably there is a different approach for this?Thank you in advance.
Regards,
MichelPosted 9 years ago # -
* small bump *
Posted 9 years ago # -
* small re-bump *
Posted 9 years ago # -
To target the dropdown field, you'll only need to change the first line of the code. To be like this:
if($data['element_type'] == 'select' && $target_is_admin === true){
MachForm Founder
Posted 9 years ago # -
Damn... Just replace 'radio' with 'select'.
I feel stupid once again. Oh well. Better to ask than pull my hair out.
Thanks Yuniar.
Posted 9 years ago # -
No rush, but wondering something.
If I use:
if($data['element_type'] == 'select' && $target_is_admin === true){ if($form_id == 10003) OR ($form_id == 10004){ if($data['element_id'] == 3){
The script stops working (blank pages, probably internal server error or something).
However this did work for radio buttons. Is this not possible with select?
Like I said; it's not a big thing, because I created now 2 seperate rules, but I always thought less code is better. :)Posted 9 years ago # -
ah.. it seems you're missing the brackets for the second IF. It should be like this:
if(($form_id == 10003) OR ($form_id == 10004)){
MachForm Founder
Posted 9 years ago # -
Argh... :|
Thanks once again Yuniar :)
Posted 9 years ago # -
Hi
Curious to understand if this would help my need. I need a select to be dependent from the previous value. Meaning that the options in the second dropdown would be filtered by a parent value in the previous select.
Any ideas on how to achieve this?
Thanks
Posted 9 years ago #
Reply
You must log in to post.