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 '
' . $html . '
'; + } + 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 '
' . $html. '
'; + if (is_numeric($this->getAttribute('options_per_line'))) { + return '
' . $html . '
'; } return $html; } diff --git a/templates/CRM/Profile/Form/Dynamic.tpl b/templates/CRM/Profile/Form/Dynamic.tpl index bd01131424d..43483b59e13 100644 --- a/templates/CRM/Profile/Form/Dynamic.tpl +++ b/templates/CRM/Profile/Form/Dynamic.tpl @@ -62,6 +62,8 @@ {/if} {assign var="profileID" value=$field.group_id} {assign var="profileFieldName" value=$field.name} + {assign var="formElement" value=$form.$profileFieldName} + {assign var="rowIdentifier" value=$field.name} {if $field.groupTitle != $fieldset} {if $mode neq 8 && $mode neq 4} @@ -99,30 +101,10 @@
{$form.$profileFieldName.label}
- {assign var="count" value=1} - {strip} - - - {* sort by fails for option per line. Added a variable to iterate through the element array*} - {foreach name=outer key=key item=item from=$form.$profileFieldName} - {* There are both numeric and non-numeric keys mixed in here, where the non-numeric are metadata that aren't arrays with html members. *} - {if is_array($item) && array_key_exists('html', $item)} - - {if $count == $field.options_per_line} - - - {assign var="count" value=1} - {else} - {assign var="count" value=$count+1} - {/if} - {/if} - {/foreach} - -
{$form.$profileFieldName.$key.html}
- {/strip} -
+ {$formElement.html} +
- {* end of main edit section div*} + {else}
diff --git a/templates/CRM/UF/Form/Fields.tpl b/templates/CRM/UF/Form/Fields.tpl index 0aaf8303055..d2a610bd558 100644 --- a/templates/CRM/UF/Form/Fields.tpl +++ b/templates/CRM/UF/Form/Fields.tpl @@ -30,10 +30,6 @@
{$formElement.html}
- {* Include the edit options list for admins *} - {if $formElement.html|strstr:"crm-option-edit-link"} - {$formElement.html|regex_replace:"@^.*()$@":"$1"} - {/if}