Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3292: Indent taxonomy forms for checkboxes and radios #4382

Merged
merged 25 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
532ee33
Issue #3292: Indent taxonomy forms for checkboxes and radios.
bugfolder Feb 24, 2023
e28e354
Break long array line per PHPCS.
bugfolder Feb 24, 2023
9b1c817
Fix LTR/RTL bug in Seven theme, simplify CSS in taxonomy module
bugfolder Feb 24, 2023
b0f79e6
Add @since to docblock.
bugfolder Feb 24, 2023
3f7a834
Improved choice of hook, better CSS attachment.
bugfolder Feb 25, 2023
3f068be
Change indentation to use theme function.
bugfolder Feb 25, 2023
a173c01
Remove superfluous attached CSS.
bugfolder Feb 25, 2023
e8c33d0
Update documentation of theme_indentation().
bugfolder Feb 25, 2023
dcd9b90
Move indentation into options, add sanitization.
bugfolder Feb 25, 2023
b2af24e
PHPCS
bugfolder Feb 25, 2023
fda55ec
Remove dots from taxonomy_allowed_values() for testing with Feeds.
bugfolder Mar 10, 2023
492af76
Remove TODO comments.
bugfolder Mar 10, 2023
9639d88
Add #indentation to term elements.
bugfolder Mar 10, 2023
de13d62
Add type hint.
bugfolder Mar 10, 2023
5b103d9
Handle missing ‘allowed_values’.
bugfolder Mar 10, 2023
3b5b870
Lighter-weight call to build $trees list without loading all terms.
bugfolder Mar 10, 2023
e4610c2
Update the check for options_list_callback override.
bugfolder Mar 12, 2023
66929af
Update core/themes/seven/css/style.css
bugfolder Mar 14, 2023
0a12b69
Typo, misplaced parenthesis.
bugfolder Mar 14, 2023
2af9159
...fix indentation not added to selects
klonos Mar 14, 2023
25bcf18
...don't be silly - use hook_field_widget_form_alter()
klonos Mar 14, 2023
4ae545b
Merge pull request #7 from klonos/issue-3292
bugfolder Mar 14, 2023
7373120
Typo
bugfolder Mar 16, 2023
999cb79
Go back to using $field['settings']['allowed_values']
bugfolder Mar 16, 2023
3828770
Update core/themes/seven/css/style.css
quicksketch Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/includes/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2582,7 +2582,7 @@ function theme_progress_bar($variables) {
}

/**
* Returns HTML for an indentation div; used for drag and drop tables.
* Returns HTML for an indentation div. Used for drag and drop tables.
*
* @param $variables
* An associative array containing:
Expand Down
30 changes: 26 additions & 4 deletions core/modules/taxonomy/taxonomy.module
Original file line number Diff line number Diff line change
Expand Up @@ -1747,18 +1747,19 @@ function taxonomy_field_formatter_settings_summary($field, $instance, $view_mode
/**
* Returns the set of valid terms for a taxonomy field.
*
* @param $field
* @param array $field
* The field definition.
* @return
*
* @return array
* The array of valid terms for this field, keyed by term id.
*/
function taxonomy_allowed_values($field) {
function taxonomy_allowed_values(array $field) {
$options = array();
foreach ($field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->machine_name, $tree['parent'])) {
foreach ($terms as $term) {
$options[$term->tid] = str_repeat('· ', $term->depth) . $term->name;
$options[$term->tid] = $term->name;
}
}
}
Expand Down Expand Up @@ -1852,6 +1853,27 @@ function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $la
return $element;
}

/**
* Implements hook_field_widget_form_alter().
*/
function taxonomy_field_widget_form_alter(&$element, &$form_state, $context) {
bugfolder marked this conversation as resolved.
Show resolved Hide resolved
$field = $context['field'];
$widget_type = $context['instance']['widget']['type'];
if ($field['type'] == 'taxonomy_term_reference' && in_array($widget_type, array('options_buttons', 'options_select'))) {
foreach ($field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->machine_name, $tree['parent'])) {
foreach ($terms as $term) {
if (isset($element['#options'][$term->tid])) {
$element[$term->tid] = array('#indentation' => $term->depth);
}
}
}
}
}
}
}

/**
* Form element validate handler for taxonomy term autocomplete element.
*/
Expand Down
9 changes: 8 additions & 1 deletion core/themes/seven/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,14 @@ div.teaser-checkbox .form-item,
.form-item input.form-radio,
.form-item input.form-checkbox {
vertical-align: middle;
margin-right: 5px;
}
.form-item input.form-radio,
.form-item input.form-checkbox {
margin-right: 5px; /* LTR */
}
[dir="rtl"] .form-item input.form-radio,
[dir="rtl"] .form-item input.form-checkbox {
margin-left: 5px;
}
.form-disabled input.form-autocomplete,
.form-disabled input.form-text,
Expand Down