public function CommentItem::fieldSettingsForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php \Drupal\comment\Plugin\Field\FieldType\CommentItem::fieldSettingsForm()
Returns a form for the field-level settings.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
Return value
array The form definition for the field settings.
Overrides FieldItemBase::fieldSettingsForm
File
- core/
modules/ comment/ src/ Plugin/ Field/ FieldType/ CommentItem.php, line 107 - Contains \Drupal\comment\Plugin\Field\FieldType\CommentItem.
Class
- CommentItem
- Plugin implementation of the 'comment' field type.
Namespace
Drupal\comment\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = array();
$settings = $this
->getSettings();
$anonymous_user = new AnonymousUserSession();
$element['default_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Threading'),
'#default_value' => $settings['default_mode'],
'#description' => t('Show comment replies in a threaded list.'),
);
$element['per_page'] = array(
'#type' => 'number',
'#title' => t('Comments per page'),
'#default_value' => $settings['per_page'],
'#required' => TRUE,
'#min' => 10,
'#max' => 1000,
'#step' => 10,
);
$element['anonymous'] = array(
'#type' => 'select',
'#title' => t('Anonymous commenting'),
'#default_value' => $settings['anonymous'],
'#options' => array(
COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
),
'#access' => $anonymous_user
->hasPermission('post comments'),
);
$element['form_location'] = array(
'#type' => 'checkbox',
'#title' => t('Show reply form on the same page as comments'),
'#default_value' => $settings['form_location'],
);
$element['preview'] = array(
'#type' => 'radios',
'#title' => t('Preview comment'),
'#default_value' => $settings['preview'],
'#options' => array(
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
DRUPAL_REQUIRED => t('Required'),
),
);
return $element;
}