function uc_ajax_admin_table in Ubercart 8.4
Same name and namespace in other branches
- 7.3 uc_ajax_admin/uc_ajax_admin.module \uc_ajax_admin_table()
TAPIr table callback for the uc_ajax administrative form.
Parameters
array $trigger_options: The select options for triggering elements.
array $wrapper_options: The select options for wrappers.
array $config: The existing configuration.
Return value
array A render array for the table.
1 call to uc_ajax_admin_table()
- AjaxAdminForm::buildForm in uc_ajax_admin/
src/ Form/ AjaxAdminForm.php
File
- uc_ajax_admin/
uc_ajax_admin.module, line 37 - Configures Ajax behaviours on the Ubercart checkout page.
Code
function uc_ajax_admin_table($trigger_options, $wrapper_options, $config) {
$build = [
'#type' => 'table',
'#tree' => TRUE,
'#header' => [
t('Triggering form element'),
t('Panes to update'),
t('Remove'),
],
];
foreach ($config as $key => $panes) {
list(, $pane) = explode('][', $key);
$build[] = [
'key' => [
'#type' => 'hidden',
'#value' => $key,
'#suffix' => empty($trigger_options[ucfirst($pane)][$key]) ? $key : ucfirst($pane) . ': ' . $trigger_options[ucfirst($pane)][$key],
],
'panes' => [
'#type' => 'select',
'#options' => $wrapper_options,
'#default_value' => $panes,
'#multiple' => TRUE,
],
'remove' => [
'#type' => 'checkbox',
'#default_value' => FALSE,
],
];
}
$build['_new'] = [
'key' => [
'#type' => 'select',
'#options' => [
0 => t('--Add a new element--'),
] + $trigger_options,
],
'panes' => [
'#type' => 'select',
'#options' => $wrapper_options,
'#multiple' => TRUE,
],
'remove' => [
'#type' => 'hidden',
'#value' => 0,
],
];
return $build;
}