function simplify_form_comment_form_alter in Simplify 8
Same name and namespace in other branches
- 7.3 simplify.module \simplify_form_comment_form_alter()
Implements hook_form_BASE_FORM_ID_alter() for comment_form().
Simplifies the "comment" form on a node to hide elements depending on settings.
File
- ./
simplify.module, line 250 - Hooks implemented by the simplify module.
Code
function simplify_form_comment_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// @todo This must be handled in a #process handler.
$comment = $form_state
->getFormObject()
->getEntity();
// Get array of fields to hide.
$global_fields = _simplify_get_config_value('simplify_comments_global');
$type_fields = _simplify_get_config_value('simplify_comments', [], 'simplify.comment_type.' . $comment
->getTypeId());
$fields = array_merge($global_fields, $type_fields);
// Hide fields.
simplify_hide_fields($fields, $form);
}