public function ChannelForm::form in Entity Share 8
Same name and namespace in other branches
- 8.3 modules/entity_share_server/src/Form/ChannelForm.php \Drupal\entity_share_server\Form\ChannelForm::form()
- 8.2 modules/entity_share_server/src/Form/ChannelForm.php \Drupal\entity_share_server\Form\ChannelForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- modules/
entity_share_server/ src/ Form/ ChannelForm.php, line 65
Class
- ChannelForm
- Class ChannelForm.
Namespace
Drupal\entity_share_server\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\entity_share_server\Entity\ChannelInterface $channel */
$channel = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $channel
->label(),
'#description' => $this
->t('Label for the channel.'),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $channel
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\entity_share_server\\Entity\\Channel::load',
],
'#disabled' => !$channel
->isNew(),
];
$form['channel_entity_type'] = [
'#type' => 'select',
'#title' => $this
->t('Entity type'),
'#options' => $this
->getEntityTypeOptions(),
'#empty_value' => '',
'#default_value' => $channel
->get('channel_entity_type'),
'#required' => TRUE,
'#ajax' => [
'callback' => [
get_class($this),
'buildAjaxBundleSelect',
],
'wrapper' => 'bundle-wrapper',
'method' => 'replace',
'effect' => 'fade',
],
];
// Container for the AJAX.
$form['bundle_wrapper'] = [
'#type' => 'container',
// Force an id because otherwise default id is changed when using AJAX.
'#attributes' => [
'id' => 'bundle-wrapper',
],
];
$this
->buildBundleSelect($form, $form_state);
$this
->buildLanguageSelect($form, $form_state);
$this
->buildGroupsTable($form, $form_state);
$this
->buildFiltersTable($form, $form_state);
$this
->buildSortsTable($form, $form_state);
$authorized_users = $channel
->get('authorized_users');
$form['authorized_users'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Authorized users'),
'#options' => $this
->getAuthorizedUsersOptions(),
'#default_value' => !is_null($authorized_users) ? $authorized_users : [],
];
return $form;
}