/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $type = $this->entity; if ($this->operation == 'add') { $form['#title'] = $this->t('Add log type'); $fields = $this->entityManager->getBaseFieldDefinitions('log'); // Create a node with a fake bundle using the type's UUID so that we can // get the default values for workflow settings. // @todo Make it possible to get default values without an entity. // https://www.drupal.org/node/2318187 $node = $this->entityManager->getStorage('log')->create(array('type' => $type->uuid())); } else { $form['#title'] = $this->t('Edit %label log type', array('%label' => $type->label())); $fields = $this->entityManager->getFieldDefinitions('log', $type->id()); // Create a node to get the current values for workflow settings fields. $node = $this->entityManager->getStorage('log')->create(array('type' => $type->id())); } $form['name'] = array('#title' => t('Name'), '#type' => 'textfield', '#default_value' => $type->label(), '#description' => t('The human-readable name of this log type. This text will be displayed as part of the list on the <em>Add content</em> page. This name must be unique.'), '#required' => TRUE, '#size' => 30); $form['type'] = array('#type' => 'machine_name', '#default_value' => $type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array('exists' => ['Drupal\\node\\Entity\\LogType', 'load'], 'source' => array('name')), '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %log-add page, in which underscores will be converted into hyphens.', array('%log-add' => t('Add content')))); $form['description'] = array('#title' => t('Description'), '#type' => 'textarea', '#default_value' => $type->getDescription(), '#description' => t('This text will be displayed on the <em>Add new content</em> page.')); $form['additional_settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('node/drupal.content_types'))); $form['submission'] = array('#type' => 'details', '#title' => t('Submission form settings'), '#group' => 'additional_settings', '#open' => TRUE); $form['submission']['preview_mode'] = array('#type' => 'radios', '#title' => t('Preview before submitting'), '#default_value' => $type->getPreviewMode(), '#options' => array(DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required'))); $form['submission']['help'] = array('#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), '#default_value' => $type->getHelp(), '#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.')); $form['workflow'] = array('#type' => 'details', '#title' => t('Publishing options'), '#group' => 'additional_settings'); $workflow_options = array('status' => $node->status->value, 'promote' => $node->promote->value, 'sticky' => $node->sticky->value, 'revision' => $type->isNewRevision()); // Prepare workflow options to be used for 'checkboxes' form element. $keys = array_keys(array_filter($workflow_options)); $workflow_options = array_combine($keys, $keys); $form['workflow']['options'] = array('#type' => 'checkboxes', '#title' => t('Default options'), '#default_value' => $workflow_options, '#options' => array('status' => t('Published'), 'promote' => t('Promoted to front page'), 'sticky' => t('Sticky at top of lists'), 'revision' => t('Create new revision')), '#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.')); $form['display'] = array('#type' => 'details', '#title' => t('Display settings'), '#group' => 'additional_settings'); $form['display']['display_submitted'] = array('#type' => 'checkbox', '#title' => t('Display author and date information'), '#default_value' => $type->displaySubmitted(), '#description' => t('Author username and publish date will be displayed.')); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); /** @var \Drupal\commerce_product\Entity\ProductTypeInterface $product_type */ $product_type = $this->entity; $variation_types = $this->variationTypeStorage->loadMultiple(); $variation_types = array_map(function ($variation_type) { return $variation_type->label(); }, $variation_types); // Create an empty product to get the default status value. // @todo Clean up once https://www.drupal.org/node/2318187 is fixed. if ($this->operation == 'add') { $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->uuid()]); } else { $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->id()]); } $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $product_type->label(), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $product_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH]; $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $product_type->getDescription()]; $form['variationType'] = ['#type' => 'select', '#title' => $this->t('Product variation type'), '#default_value' => $product_type->getVariationType(), '#options' => $variation_types, '#required' => TRUE]; $form['product_status'] = ['#type' => 'checkbox', '#title' => t('Publish new products of this type by default.'), '#default_value' => $product->isPublished()]; if ($this->moduleHandler->moduleExists('language')) { $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings']; $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product', 'bundle' => $product_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product', $product_type->id())]; $form['#submit'][] = 'language_configuration_element_submit'; } return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $paymentInformationType = $this->entity; $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $paymentInformationType->label(), '#description' => $this->t('Label for the payment information type.'), '#required' => TRUE, ); $form['id'] = array( '#type' => 'machine_name', '#default_value' => $paymentInformationType->id(), '#machine_name' => array( 'exists' => array($this->paymentInfoTypeStorage, 'load'), 'source' => array('label'), ), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, ); $form['description'] = array( '#title' => t('Description'), '#type' => 'textarea', '#default_value' => $paymentInformationType->getDescription(), '#description' => $this->t('Description of this payment information type'), ); return $this->protectBundleIdElement($form);; }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $vocabulary = $this->entity; if ($vocabulary->isNew()) { $form['#title'] = $this->t('Add vocabulary'); } else { $form['#title'] = $this->t('Edit vocabulary'); } $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $vocabulary->label(), '#maxlength' => 255, '#required' => TRUE); $form['vid'] = array('#type' => 'machine_name', '#default_value' => $vocabulary->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array('exists' => array($this, 'exists'), 'source' => array('name'))); $form['description'] = array('#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $vocabulary->getDescription()); // $form['langcode'] is not wrapped in an // if ($this->moduleHandler->moduleExists('language')) check because the // language_select form element works also without the language module being // installed. https://www.drupal.org/node/1749954 documents the new element. $form['langcode'] = array('#type' => 'language_select', '#title' => $this->t('Vocabulary language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $vocabulary->language()->getId()); if ($this->moduleHandler->moduleExists('language')) { $form['default_terms_language'] = array('#type' => 'details', '#title' => $this->t('Terms language'), '#open' => TRUE); $form['default_terms_language']['default_language'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'taxonomy_term', 'bundle' => $vocabulary->id()), '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vocabulary->id())); } // Set the hierarchy to "multiple parents" by default. This simplifies the // vocabulary form and standardizes the term form. $form['hierarchy'] = array('#type' => 'value', '#value' => '0'); $form = parent::form($form, $form_state); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); /** @var \Drupal\commerce_product\Entity\ProductVariationTypeInterface $variation_type */ $variation_type = $this->entity; $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $variation_type->label(), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $variation_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductVariationType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH]; $form['generateTitle'] = ['#type' => 'checkbox', '#title' => t('Generate variation titles based on attribute values.'), '#default_value' => $variation_type->shouldGenerateTitle()]; if (\Drupal::moduleHandler()->moduleExists('commerce_order')) { // Prepare a list of line item types used to purchase product variations. $line_item_type_storage = $this->entityTypeManager->getStorage('commerce_line_item_type'); $line_item_types = $line_item_type_storage->loadMultiple(); $line_item_types = array_filter($line_item_types, function ($line_item_type) { return $line_item_type->getPurchasableEntityTypeId() == 'commerce_product_variation'; }); $line_item_types = array_map(function ($line_item_type) { return $line_item_type->label(); }, $line_item_types); $form['lineItemType'] = ['#type' => 'select', '#title' => $this->t('Line item type'), '#default_value' => $variation_type->getLineItemTypeId(), '#options' => $line_item_types, '#empty_value' => '', '#required' => TRUE]; } if ($this->moduleHandler->moduleExists('language')) { $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings']; $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product_variation', 'bundle' => $variation_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product_variation', $variation_type->id())]; $form['#submit'][] = 'language_configuration_element_submit'; } return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $this->entity->label(), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $this->entity->id(), '#machine_name' => ['exists' => '\\Drupal\\conference_sessions\\Entity\\RoomType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH]; $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $this->entity->getDescription()]; return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; $form['label'] = array('#type' => 'textfield', '#title' => t('Set name'), '#description' => t('The new set is created by copying items from your default shortcut set.'), '#required' => TRUE, '#default_value' => $entity->label()); $form['id'] = array('#type' => 'machine_name', '#machine_name' => array('exists' => '\\Drupal\\shortcut\\Entity\\ShortcutSet::load', 'source' => array('label'), 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-'), '#default_value' => $entity->id(), '#maxlength' => 23); $form['actions']['submit']['#value'] = t('Create new set'); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; $form['label'] = array('#type' => 'textfield', '#title' => t('Set name'), '#description' => t('Add a name for this grade letter set.'), '#required' => TRUE, '#default_value' => $entity->label()); $form['id'] = array('#type' => 'machine_name', '#machine_name' => array('exists' => '\\Drupal\\gradebook\\Entity\\GradeLetterSet::load', 'source' => array('label'), 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-'), '#default_value' => $entity->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH); $form['actions']['submit']['#value'] = t('Create new set'); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $order_type = $this->entity; $workflow_manager = \Drupal::service('plugin.manager.workflow'); $workflows = $workflow_manager->getGroupedLabels('commerce_order'); $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $order_type->label(), '#description' => $this->t('Label for the order type.'), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $order_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_order\\Entity\\OrderType::load', 'source' => ['label']], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH]; $form['workflow'] = ['#type' => 'select', '#title' => t('Workflow'), '#options' => $workflows, '#default_value' => $order_type->getWorkflowId(), '#description' => $this->t('Used by all orders of this type.')]; return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $lineItemType = $this->entity; // Prepare the list of purchasable entity types. $entityTypes = $this->entityTypeManager->getDefinitions(); $purchasableEntityTypes = array_filter($entityTypes, function ($entityType) { return $entityType->isSubclassOf('\Drupal\commerce\PurchasableEntityInterface'); }); $purchasableEntityTypes = array_map(function ($entityType) { return $entityType->getLabel(); }, $purchasableEntityTypes); // Prepare the list of order types. $orderTypes = $this->entityTypeManager->getStorage('commerce_order_type') ->loadMultiple(); $orderTypes = array_map(function ($orderType) { return $orderType->label(); }, $orderTypes); $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $lineItemType->label(), '#description' => $this->t('Label for the line item type.'), '#required' => TRUE, ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $lineItemType->id(), '#machine_name' => [ 'exists' => '\Drupal\commerce_order\Entity\LineItemType::load', 'source' => ['label'], ], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, ]; $form['purchasableEntityType'] = [ '#type' => 'select', '#title' => $this->t('Purchasable entity type'), '#default_value' => $lineItemType->getPurchasableEntityType(), '#options' => $purchasableEntityTypes, '#empty_value' => '', '#disabled' => !$lineItemType->isNew(), ]; $form['orderType'] = [ '#type' => 'select', '#title' => $this->t('Order type'), '#default_value' => $lineItemType->getOrderType(), '#options' => $orderTypes, '#required' => TRUE, ]; return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $store_type = $this->entity; $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $store_type->label(), '#description' => $this->t('Label for the store type.'), '#required' => TRUE]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $store_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_store\\Entity\\StoreType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH]; $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $store_type->getDescription()]; if ($this->moduleHandler->moduleExists('language')) { $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings']; $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_store', 'bundle' => $store_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_store', $store_type->id())]; $form['#submit'][] = 'language_configuration_element_submit'; } return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $rdf_type = $this->entity; if ($rdf_type->isNew()) { $form['#title'] = $this->t('Add rdf type'); } else { $form['#title'] = $this->t('Edit rdf type'); } $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $rdf_type->label(), '#maxlength' => 255, '#required' => TRUE); $form['rid'] = array('#type' => 'machine_name', '#default_value' => $rdf_type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array('exists' => array($this, 'exists'), 'source' => array('name'))); $form['description'] = array('#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => isset($rdf_type->description) ? $rdf_type->description : ''); $form = parent::form($form, $form_state); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $type = $this->entity; if ($this->operation == 'add') { $form['#title'] = $this->t('Add profile type'); } else { $form['#title'] = $this->t('Edit %label profile type', ['%label' => $type->label()]); } $form['label'] = ['#title' => t('Label'), '#type' => 'textfield', '#default_value' => $type->label(), '#description' => t('The human-readable name of this profile type.'), '#required' => TRUE, '#size' => 30]; $form['id'] = ['#type' => 'machine_name', '#default_value' => $type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => ['exists' => '\\Drupal\\profile\\Entity\\ProfileType::load', 'source' => ['label']]]; $form['registration'] = ['#type' => 'checkbox', '#title' => t('Include in user registration form'), '#default_value' => $type->getRegistration()]; $form['multiple'] = ['#type' => 'checkbox', '#title' => t('Allow multiple profiles'), '#default_value' => $type->getMultiple()]; $form['roles'] = ['#type' => 'checkboxes', '#title' => t('Allowed roles'), '#description' => $this->t('Limit the users that can have this profile by role.</br><em>None will indicate that all users can have this profile type.</em>'), '#options' => [], '#default_value' => $type->getRoles()]; foreach (Role::loadMultiple() as $role) { /** @var \Drupal\user\Entity\Role $role */ // We aren't interested in anon role. if ($role->id() !== Role::ANONYMOUS_ID) { $form['roles']['#options'][$role->id()] = $role->label(); } } return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); /* @var \Drupal\block_content\BlockContentTypeInterface $block_type */ $block_type = $this->entity; if ($this->operation == 'add') { $form['#title'] = $this->t('Add custom block type'); } else { $form['#title'] = $this->t('Edit %label custom block type', array('%label' => $block_type->label())); } $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $block_type->label(), '#description' => t("Provide a label for this block type to help identify it in the administration pages."), '#required' => TRUE); $form['id'] = array('#type' => 'machine_name', '#default_value' => $block_type->id(), '#machine_name' => array('exists' => '\\Drupal\\block_content\\Entity\\BlockContentType::load'), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH); $form['description'] = array('#type' => 'textarea', '#default_value' => $block_type->getDescription(), '#description' => t('Enter a description for this block type.'), '#title' => t('Description')); $form['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $block_type->shouldCreateNewRevision(), '#description' => t('Create a new revision by default for this block type.')); if ($this->moduleHandler->moduleExists('language')) { $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings'); $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id()); $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'block_content', 'bundle' => $block_type->id()), '#default_value' => $language_configuration); $form['#submit'][] = 'language_configuration_element_submit'; } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save')); return $this->protectBundleIdElement($form); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $productType = $this->entity; $variationTypes = $this->variationTypeStorage->loadMultiple(); $variationTypes = array_map(function($variationType) { return $variationType->label(); }, $variationTypes); $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $productType->label(), '#required' => TRUE, ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $productType->id(), '#machine_name' => [ 'exists' => '\Drupal\commerce_product\Entity\ProductType::load', ], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, ]; $form['description'] = [ '#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $productType->getDescription(), ]; $form['variationType'] = [ '#type' => 'select', '#title' => $this->t('Product variation type'), '#default_value' => $productType->getVariationType(), '#options' => $variationTypes, '#required' => TRUE, ]; $form['digital'] = [ '#type' => 'checkbox', '#title' => t('Digital'), '#default_value' => $productType->isDigital(), '#description' => t('Products of this type represent digital services.') ]; if ($this->moduleHandler->moduleExists('language')) { $form['language'] = [ '#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings', ]; $form['language']['language_configuration'] = [ '#type' => 'language_configuration', '#entity_information' => [ 'entity_type' => 'commerce_product', 'bundle' => $productType->id(), ], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product', $productType->id()), ]; $form['#submit'][] = 'language_configuration_element_submit'; } return $this->protectBundleIdElement($form);; }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $queue = $this->entity; $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $queue->label(), '#description' => $this->t("Label for the EntityQueue."), '#required' => TRUE, ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $queue->id(), '#machine_name' => [ 'exists' => '\Drupal\entityqueue\Entity\EntityQueue::load', ], '#disabled' => !$queue->isNew(), ]; $handlers = $this->entityQueueHandlerManager->getAllEntityQueueHandlers(); $form['handler'] = [ '#type' => 'radios', '#title' => $this->t('Handler'), '#options' => $handlers, '#default_value' => $queue->getHandler(), '#required' => TRUE, '#disabled' => !$queue->isNew(), ]; // @todo It should be up to the queue handler to determine what entity types // are queue-able. $form['target_type'] = [ '#type' => 'select', '#title' => $this->t('Type of items to queue'), '#options' => \Drupal::entityManager()->getEntityTypeLabels(TRUE), '#default_value' => $queue->getTargetEntityTypeId(), '#required' => TRUE, '#disabled' => !$queue->isNew(), '#size' => 1, ]; $form['settings'] = [ '#type' => 'vertical_tabs', ]; $form['properties'] = [ '#type' => 'details', '#title' => $this->t('Queue properties'), '#open' => TRUE, '#group' => 'settings', ]; $form['properties']['size'] = [ '#type' => 'container', '#attributes' => ['class' => ['form--inline', 'clearfix']], ]; $form['properties']['size']['min_size'] = [ '#type' => 'number', '#size' => 2, '#default_value' => $queue->getMinimumSize(), '#field_prefix' => $this->t('Restrict this queue to a minimum of'), ]; $form['properties']['size']['max_size'] = [ '#type' => 'number', '#default_value' => $queue->getMaximumSize(), '#field_prefix' => $this->t('and a maximum of'), '#field_suffix' => $this->t('items.'), ]; $form['properties']['act_as_queue'] = [ '#type' => 'checkbox', '#title' => t('Act as queue'), '#default_value' => $queue->getActAsQueue(), '#description' => $this->t('When enabled, adding more than the maximum number of items will remove extra items from the top of the queue.'), '#states' => [ 'invisible' => [ ':input[name="max_size"]' => ['value' => 0], ], ], ]; return $form; }