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?


  1. MvdL79
    Member

    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,
    Michel

    Posted 9 years ago #
  2. MvdL79
    Member

    * small bump *

    Posted 9 years ago #
  3. MvdL79
    Member

    * small re-bump *

    Posted 9 years ago #
  4. yuniar

    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 #
  5. MvdL79
    Member

    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 #
  6. MvdL79
    Member

    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 #
  7. yuniar

    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 #
  8. MvdL79
    Member

    Argh... :|

    Thanks once again Yuniar :)

    Posted 9 years ago #
  9. offcourse
    Member

    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 #

RSS feed for this topic

Reply