Created
April 2, 2020 13:53
-
-
Save kagg-design/de973858ec3f7104098e7024ed7ba9d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author OnTheGo Systems | |
*/ | |
class GFML_Conditional_Logic extends GFML_Form { | |
/** | |
* It translates the attributes of the conditional logic, before translating the fields. | |
* This is necessary, or it would not be possible to adjust the conditional logic based on values from "choices" fields. | |
* | |
* @param array $form | |
* @param string $st_context | |
* | |
* @return array | |
*/ | |
public function translate_conditional_logic( $form, $st_context ) { | |
foreach ( $form['fields'] as $id => &$field ) { | |
if ( $field->conditionalLogic && $field->conditionalLogic['rules'] ) { | |
foreach ( $field->conditionalLogic['rules'] as &$rule ) { | |
$rule_field = $this->get_field_from_rule( $form, $rule ); | |
if ( isset( $rule_field->choices ) && is_array( $rule_field->choices ) ) { | |
$translations = $this->get_multi_input_translations( $rule_field, $st_context ); | |
if ( isset( $rule['value'] ) && isset( $translations[ $rule['value'] ] ) ) { | |
$rule['value'] = $translations[ $rule['value'] ]; | |
} | |
} | |
} | |
} | |
} | |
return $form; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment