Orkun Posted June 8, 2016 Share Posted June 8, 2016 Hi Guys Do you know how I could do multiple conditions (OR) with the Inputfield Dependencies with the Form API? At the moment I am doing this but that doesn't work: $showIfSelector = ""; foreach ($optionsArray as $list_id => $values) { $field = $this->modules->get("InputfieldSelect"); $field->label = "Field Parameter"; $field->attr("name", "fieldParam_".$list_id); //$field->columnWidth = 40; $field->showIf = "list_id=$list_id, method_recipient=groupSegment"; foreach ($values as $optgroup => $fieldValues) { if(array_key_exists($optgroup, $values)){ $field->addOption($optgroup, $fieldValues); } } $conditionContainer->add($field); $showIfSelector .= "fieldParam_$list_id%=mergefield, "; } $showIfSelector = trim($showIfSelector, ", "); $field = $this->modules->get("InputfieldSelect"); $field->label = "Logical Operator"; $field->attr("name", "operatorParamSeg_".$list_id); $field->addOptions(array( 'is' => "is", 'not' => "is not", 'contains' => "contains", 'notcontain' => "does not contain", 'starts' => "starts with", 'ends' => "ends with", 'greater' => "is greater than", 'less' => "is less than", 'blank' => "is blank", 'blank_not' => "is not blank" )); $field->showIf = "list_id=$list_id, method_recipient=groupSegment, $showIfSelector"; $conditionContainer->add($field); $field = $this->modules->get("InputfieldText"); $field->label = "Search Parameter"; $field->attr("name", "searchParam_".$list_id); $field->showIf = "list_id=$list_id, method_recipient=groupSegment, $showIfSelector"; $conditionContainer->add($field); I am generating multiple Selects for my different Values. Everytime I select a List, it would show me the right fieldParam Field with the right mergefields and groups values. So at the moment I have multiple "names" which containe the phrase fieldParam + _listID. So I create a showIfSelector Var which will be filled with all possible conditions for every Select. After that i give the $showIfSelector to my showIf option inside "operatorParamSeg" and "searchParam" Inputfield. Now It should show me the operator select and the search inputfield everytime when i Select a mergefield in the fieldParam. With this way I don't have to render the search and operator Inputfield multiple times inside the foreach. PS: I know my English is terrible at the moment because I am not focused. Why I am not focused? Because I am tired. Why I am tired? Because I have watched to much series last night. Greetings Orkun Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now