Skip to content
Snippets Groups Projects
Commit 230a24dd authored by Jay Friendly's avatar Jay Friendly
Browse files

adding option to remove text format description from message form through admin interface

parent e30a5598
No related branches found
No related tags found
No related merge requests found
enable_email_notifications: true
send_by_default: true
hide_form_filter_tips: false
......@@ -36,6 +36,9 @@ private_message.settings:
send_by_default:
type: boolean
label: 'Whether to send emails by default. Users will be able to alter this behavior in their profiles'
hide_form_filter_tips:
type: boolean
label: "Whether or not to hide the filter tips on the message form"
private_message.mail:
type: config_object
......
......@@ -49,6 +49,13 @@ class ConfigForm extends ConfigFormBase {
],
];
$form['hide_form_filter_tips'] = [
'#type' => 'checkbox',
'#title' => $this->t('Hide filter tips'),
'#description' => $this->t('If this box is checked, the text formats description on the private message form will be removed'),
'#default_value' => (int) $config->get('hide_form_filter_tips'),
];
return parent::buildForm($form, $form_state);
}
......@@ -59,6 +66,7 @@ class ConfigForm extends ConfigFormBase {
$this->config('private_message.settings')
->set('enable_email_notifications', (bool) $form_state->getValue('enable_email_notifications'))
->set('send_by_default', (bool) $form_state->getValue('send_by_default'))
->set('hide_form_filter_tips', (bool) $form_state->getValue('hide_form_filter_tips'))
->save();
parent::submitForm($form, $form_state);
......
......@@ -162,6 +162,10 @@ class PrivateMessageForm extends ContentEntityForm {
$form['#validate'][] = '::validateMembers';
}
if($this->config->get('hide_form_filter_tips')) {
$form['#after_build'][] = '::afterBuild';
}
return $form;
}
......@@ -227,6 +231,15 @@ class PrivateMessageForm extends ContentEntityForm {
return $response;
}
/**
* After build callback for the Private Message Form
*/
public function afterBuild(array $form, FormStateInterface $form_state) {
$form['message']['widget'][0]['format']['#access'] = FALSE;
return $form;
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment