You are here

class WorkflowTypeConfigureForm in Workflows Field 8

Same name and namespace in other branches
  1. 2.x src/Form/WorkflowTypeConfigureForm.php \Drupal\workflows_field\Form\WorkflowTypeConfigureForm

Plugin form for the workflows field.

Hierarchy

Expanded class hierarchy of WorkflowTypeConfigureForm

File

src/Form/WorkflowTypeConfigureForm.php, line 12

Namespace

Drupal\workflows_field\Form
View source
class WorkflowTypeConfigureForm extends WorkflowTypeConfigureFormBase {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $configuration = $this->workflowType
      ->getConfiguration();
    $form['settings'] = [
      '#title' => $this
        ->t('Workflow Settings'),
      '#type' => 'fieldset',
    ];
    $labels = array_map([
      State::class,
      'labelCallback',
    ], $this->workflowType
      ->getStates());
    $form['settings']['initial_state'] = [
      '#title' => $this
        ->t('Initial State'),
      '#type' => 'select',
      '#default_value' => isset($configuration['initial_state']) ? $configuration['initial_state'] : NULL,
      '#options' => $labels,
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $configuration = $this->workflowType
      ->getConfiguration();
    $configuration['initial_state'] = $form_state
      ->getValue([
      'settings',
      'initial_state',
    ]);
    $this->workflowType
      ->setConfiguration($configuration);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
WorkflowTypeConfigureForm::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm
WorkflowTypeConfigureForm::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
WorkflowTypeConfigureFormBase::$workflowType protected property The workflow type.
WorkflowTypeConfigureFormBase::setPlugin public function Sets the plugin for this object. Overrides PluginAwareInterface::setPlugin
WorkflowTypeConfigureFormBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm