function _social_group_flexible_group_type_change_topic_icon_ajax in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/social_group_flexible_group.module \_social_group_flexible_group_type_change_topic_icon_ajax()
- 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/social_group_flexible_group.module \_social_group_flexible_group_type_change_topic_icon_ajax()
- 10.2.x modules/social_features/social_group/modules/social_group_flexible_group/social_group_flexible_group.module \_social_group_flexible_group_type_change_topic_icon_ajax()
Ajax callback to change group type icon.
1 string reference to '_social_group_flexible_group_type_change_topic_icon_ajax'
- social_group_flexible_group_form_taxonomy_term_group_type_form_alter in modules/
social_features/ social_group/ modules/ social_group_flexible_group/ social_group_flexible_group.module - Implements hook_form_FORM_ID_alter().
File
- modules/
social_features/ social_group/ modules/ social_group_flexible_group/ social_group_flexible_group.module, line 846 - The Social Group Flexible Group module.
Code
function _social_group_flexible_group_type_change_topic_icon_ajax(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$icon = $form_state
->getValue('field_group_type_icon')[0]['value'];
$replaced = [
'#type' => 'inline_template',
'#template' => '<div class="icon-svg-wrapper" data-href="#' . $icon . '"><svg class="selected-svg"><use xlink:href="#' . $icon . '"></use></svg>{{ svg_icons|raw }}</div>',
'#context' => [
'svg_icons' => file_get_contents(drupal_get_path('theme', 'socialbase') . '/assets/icons/icons.svg'),
],
];
$response
->addCommand(new ReplaceCommand('.icon-svg-wrapper', $replaced));
return $response;
}