Skip to content

Commit bd318f1

Browse files
committed
chore: use switch field types
1 parent 11046ce commit bd318f1

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

views/default/forms/widgets/advanced.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use ColdTrick\WidgetManager\WidgetsSettingsConfig;
34

45
$widget = elgg_extract('entity', $vars);
@@ -61,13 +62,10 @@
6162

6263
if ((bool) elgg_get_plugin_setting('lazy_loading_enabled', 'widget_manager') && !WidgetsSettingsConfig::instance()->getSetting($widget->handler, 'always_lazy_load', (string) $widget->context)) {
6364
$fields[] = [
64-
'#type' => 'checkbox',
65+
'#type' => 'switch',
6566
'#label' => elgg_echo('widget_manager:widgets:edit:lazy_load_content'),
6667
'name' => 'params[widget_manager_lazy_load_content]',
67-
'checked' => !empty($widget->widget_manager_lazy_load_content),
68-
'switch' => true,
69-
'default' => 0,
70-
'value' => 1,
68+
'value' => $widget->widget_manager_lazy_load_content,
7169
];
7270
}
7371
}

views/default/plugins/widget_manager/settings.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,19 @@
9494
}
9595

9696
$lazy_settings = elgg_view_field([
97-
'#type' => 'checkbox',
97+
'#type' => 'switch',
9898
'#label' => elgg_echo('widget_manager:settings:lazy_loading:enabled'),
9999
'#help' => elgg_echo('widget_manager:settings:lazy_loading:enabled:help'),
100100
'name' => 'params[lazy_loading_enabled]',
101-
'checked' => (bool) $plugin->lazy_loading_enabled,
102-
'switch' => true,
103-
'default' => 0,
104-
'value' => 1,
101+
'value' => $plugin->lazy_loading_enabled,
105102
]);
106103

107104
$lazy_settings .= elgg_view_field([
108-
'#type' => 'checkbox',
105+
'#type' => 'switch',
109106
'#label' => elgg_echo('widget_manager:settings:lazy_loading:lazy_loading_mobile_columns'),
110107
'#help' => elgg_echo('widget_manager:settings:lazy_loading:lazy_loading_mobile_columns:help'),
111108
'name' => 'params[lazy_loading_mobile_columns]',
112-
'checked' => (bool) $plugin->lazy_loading_mobile_columns,
113-
'switch' => true,
114-
'default' => 0,
115-
'value' => 1,
109+
'value' => $plugin->lazy_loading_mobile_columns,
116110
]);
117111

118112
$lazy_settings .= elgg_view_field([
@@ -127,14 +121,11 @@
127121
echo elgg_view_module('info', elgg_echo('widget_manager:settings:lazy_loading'), $lazy_settings);
128122

129123
$other_settings = elgg_view_field([
130-
'#type' => 'checkbox',
124+
'#type' => 'switch',
131125
'#label' => elgg_echo('widget_manager:settings:show_collapse_content'),
132126
'#help' => elgg_echo('widget_manager:settings:show_collapse_content:help'),
133127
'name' => 'params[show_collapse_content]',
134-
'checked' => (bool) $plugin->show_collapse_content,
135-
'switch' => true,
136-
'default' => 0,
137-
'value' => 1,
128+
'value' => $plugin->show_collapse_content,
138129
]);
139130

140131
echo elgg_view_module('info', elgg_echo('widget_manager:settings:other'), $other_settings);

0 commit comments

Comments
 (0)