diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 4e088ed53a0..577b38213c0 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -391,6 +391,7 @@ public function __construct( } $this->_action = (int) $action; $this->registerElementType('radio_with_div', 'CRM/Core/QuickForm/RadioWithDiv.php', 'CRM_Core_QuickForm_RadioWithDiv'); + $this->registerElementType('group_with_div', 'CRM/Core/QuickForm/GroupWithDiv.php', 'CRM_Core_QuickForm_GroupWithDiv'); $this->registerRules(); // let the constructor initialize this, should happen only once @@ -1497,7 +1498,13 @@ public function &addRadio($name, $title, $values, $attributes = [], $separator = $element = $this->createElement('radio_with_div', NULL, NULL, $var, $key, $optAttributes); $options[] = $element; } - $group = $this->addGroup($options, $name, $title, $separator); + if (!empty($attributes['options_per_line'])) { + $group = $this->addElement('group_with_div', $name, $title, $options, $separator, TRUE); + $group->setAttribute('options_per_line', $attributes['options_per_line']); + } + else { + $group = $this->addGroup($options, $name, $title, $separator); + } $optionEditKey = 'data-option-edit-path'; if (!empty($attributes[$optionEditKey])) { diff --git a/CRM/Core/QuickForm/GroupWithDiv.php b/CRM/Core/QuickForm/GroupWithDiv.php new file mode 100644 index 00000000000..07dfe354049 --- /dev/null +++ b/CRM/Core/QuickForm/GroupWithDiv.php @@ -0,0 +1,41 @@ +getAttribute('options_per_line'))) { + return '
'; + } + return $html; + } + +} diff --git a/CRM/Core/QuickForm/RadioWithDiv.php b/CRM/Core/QuickForm/RadioWithDiv.php index 8075f2c98ef..c421e584351 100644 --- a/CRM/Core/QuickForm/RadioWithDiv.php +++ b/CRM/Core/QuickForm/RadioWithDiv.php @@ -30,11 +30,10 @@ class CRM_Core_QuickForm_RadioWithDiv extends HTML_QuickForm_radio { * @access public * @return string */ - function toHtml() - { + public function toHtml(): string { $html = parent::toHtml(); - if (is_numeric( $this->getAttribute('options_per_line'))) { - return '{$form.$profileFieldName.$key.html} | - {if $count == $field.options_per_line} -