Skip to main content
added 147 characters in body
Source Link

Profile conditional ext can be used to provide this - https://civicrm.org/extensions/profile-conditionals

You dont have any UI option to build the conditions. But this can be easily done in civicrm.settings.php. The config we used for select-other field is pasted below -

  • custom_229 is the dropdown field wth options + other
  • custom_230 is the "Other" Text field.
global $civicrm_setting;
$select_other = [
  'onload' => [
    'selectors' => [
      '#editrow-custom_230' => [
        'display' => 'hide',
      ],
    ],
  ],
  'select-other' => [
    'conditions' => [
      'all_of' => [
        [
          'id' => 'custom_229',
          'op' => 'value_is',
          'value' => '7', //Other
        ],
      ]
    ],
    'states' => [
      'pass' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'show',
          ],
        ],
      ],
      'fail' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'hide',
          ],
          //Clear the text value if other is not selected in the dropdown
          '#custom_230' => [
            'value' => '',
          ],
        ],
      ],
    ],
  ],
];

//Apply thisthe conditionsabove oncondition to contribution page id 22, 23 and 24
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond'] = [
  'contribution' => [
    22 => $select_other,
    23 => $select_other,
    24 => $select_other,
  ],
];

Profile conditional ext can be used to provide this - https://civicrm.org/extensions/profile-conditionals

You dont have any UI option to build the conditions. But this can be easily done in civicrm.settings.php. The config we used for select-other field is pasted below -

  • custom_229 is the dropdown field wth options + other
  • custom_230 is the "Other" Text field.
global $civicrm_setting;
$select_other = [
  'onload' => [
    'selectors' => [
      '#editrow-custom_230' => [
        'display' => 'hide',
      ],
    ],
  ],
  'select-other' => [
    'conditions' => [
      'all_of' => [
        [
          'id' => 'custom_229',
          'op' => 'value_is',
          'value' => '7', //Other
        ],
      ]
    ],
    'states' => [
      'pass' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'show',
          ],
        ],
      ],
      'fail' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'hide',
          ],
        ],
      ],
    ],
  ],
];

//Apply this conditions on contribution page id 22, 23 and 24
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond'] = [
  'contribution' => [
    22 => $select_other,
    23 => $select_other,
    24 => $select_other,
  ],
];

Profile conditional ext can be used to provide this - https://civicrm.org/extensions/profile-conditionals

You dont have any UI option to build the conditions. But this can be easily done in civicrm.settings.php. The config we used for select-other field is pasted below -

  • custom_229 is the dropdown field wth options + other
  • custom_230 is the "Other" Text field.
global $civicrm_setting;
$select_other = [
  'onload' => [
    'selectors' => [
      '#editrow-custom_230' => [
        'display' => 'hide',
      ],
    ],
  ],
  'select-other' => [
    'conditions' => [
      'all_of' => [
        [
          'id' => 'custom_229',
          'op' => 'value_is',
          'value' => '7', //Other
        ],
      ]
    ],
    'states' => [
      'pass' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'show',
          ],
        ],
      ],
      'fail' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'hide',
          ],
          //Clear the text value if other is not selected in the dropdown
          '#custom_230' => [
            'value' => '',
          ],
        ],
      ],
    ],
  ],
];

//Apply the above condition to contribution page id 22, 23 and 24
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond'] = [
  'contribution' => [
    22 => $select_other,
    23 => $select_other,
    24 => $select_other,
  ],
];
Source Link

Profile conditional ext can be used to provide this - https://civicrm.org/extensions/profile-conditionals

You dont have any UI option to build the conditions. But this can be easily done in civicrm.settings.php. The config we used for select-other field is pasted below -

  • custom_229 is the dropdown field wth options + other
  • custom_230 is the "Other" Text field.
global $civicrm_setting;
$select_other = [
  'onload' => [
    'selectors' => [
      '#editrow-custom_230' => [
        'display' => 'hide',
      ],
    ],
  ],
  'select-other' => [
    'conditions' => [
      'all_of' => [
        [
          'id' => 'custom_229',
          'op' => 'value_is',
          'value' => '7', //Other
        ],
      ]
    ],
    'states' => [
      'pass' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'show',
          ],
        ],
      ],
      'fail' => [
        'selectors' => [
          '#editrow-custom_230' => [
            'display' => 'hide',
          ],
        ],
      ],
    ],
  ],
];

//Apply this conditions on contribution page id 22, 23 and 24
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond'] = [
  'contribution' => [
    22 => $select_other,
    23 => $select_other,
    24 => $select_other,
  ],
];