You are here

protected function SocialAlbumPostForm::configureVisibilityField in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::configureVisibilityField()
  2. 10.0.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::configureVisibilityField()
  3. 10.1.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::configureVisibilityField()

Configures the allows values for the visiblity field.

Uses whether this is a new entity or an existing entity and which view mode is used to configure the allowed values of the visibility field. This is different for posts made to a profile or in a group.

When editing a visibility is shown but can not be altered.

For the meaning of the numbers in this function check the field definition in the field.storage.post.field_visibility configuration object.

Parameters

array $form: The post form being rendered.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

Overrides PostForm::configureVisibilityField

File

modules/social_features/social_album/src/Form/SocialAlbumPostForm.php, line 97

Class

SocialAlbumPostForm
Provides form for creating a post in an album.

Namespace

Drupal\social_album\Form

Code

protected function configureVisibilityField(array &$form, FormStateInterface $form_state) {
  parent::configureVisibilityField($form, $form_state);
  if ($this->node) {
    $field =& $form['field_visibility']['widget'][0];
    $value = self::VISIBILITY_MAPPING[$this->node->field_content_visibility->value];
    if (isset($field['#options'][$value])) {
      $field['#default_value'] = $value;
    }
    $field['#edit_mode'] = TRUE;
  }
}