/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\drupalbristol_sponsors\Entity\SponsorEntity */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->entity->getConfiguration();
     $manager = $this->entity->getType() == 'condition' ? 'conditionManager' : 'actionManager';
     $this->plugin = $this->{$manager}->createInstance($this->entity->getPluginId(), $config);
     return parent::buildForm($form, $form_state);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\component\Entity\Component */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\drupal8_entity\Entity\Drupal8EntityItem */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->langcode->value, '#languages' => Language::STATE_ALL);
     return $form;
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\content_entity_example\Entity\Contact */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL);
     return $form;
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     // The widgets are allowed to signal that the form should be hidden
     // (because there's no purchasable entity to select, for example).
     if ($form_state->get('hide_form')) {
         $form['#access'] = FALSE;
     }
     return $form;
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     parent::buildForm($form, $form_state);
     $roles = tmgmt_local_translator_roles();
     if (empty($roles)) {
         drupal_set_message(t('No user role has the "provide translation services" permission. <a href="@url">Configure permissions</a> for the Drupal user module.', array('@url' => URL::fromRoute('user.admin_permissions'))), 'warning');
     }
     $form['tuid'] = array('#title' => t('Assign to'), '#type' => 'select', '#empty_option' => t('- Select user -'), '#options' => tmgmt_local_get_assignees_for_tasks([$this->getEntity()->id()]), '#required' => TRUE);
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Assign tasks'));
     return $form;
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\custom_page\Entity\CustomPage */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['metatags'] = array('#type' => 'details', '#title' => 'Meta tags');
     $form['metatags']['meta_title'] = $form['meta_title'];
     $form['metatags']['meta_description'] = $form['meta_description'];
     unset($form['meta_title']);
     unset($form['meta_description']);
     return $form;
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Skip building the form if there are no available stores.
     $store_query = $this->entityManager->getStorage('commerce_store')->getQuery();
     if ($store_query->count()->execute() == 0) {
         $options = ['query' => ['destination' => Url::fromRoute('<current>')->toString()]];
         $link = Link::createFromRoute('Add a new store.', 'entity.commerce_store.add_page', [], $options);
         $form['warning'] = ['#markup' => t("Products can't be created until a store has been added. @link", ['@link' => $link->toString()])];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $form['#title'] = $this->getQuestion();
     $form['#attributes']['class'][] = 'confirmation';
     $form['description'] = array('#markup' => $this->getDescription());
     $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);
     // By default, render the form using theme_confirm_form().
     if (!isset($form['#theme'])) {
         $form['#theme'] = 'confirm_form';
     }
     return $form;
 }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    /* @var $entity \Drupal\product_search\Entity\PoliticalDivision */
    $form = parent::buildForm($form, $form_state);
    $entity = $this->entity;

    $form['langcode'] = array(
      '#title' => $this->t('Language'),
      '#type' => 'language_select',
      '#default_value' => $entity->getUntranslated()->language()->getId(),
      '#languages' => Language::STATE_ALL,
    );

    return $form;
  }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\myeck\Entity\Myeck */
     $form = parent::buildForm($form, $form_state);
     //сделать универсальное для всех !!!!!!!!!!!!!!!
     //    $entity = $this->entity;
     //    $form['langcode'] = array(
     //      '#title' => $this->t('Language'),
     //      '#type' => 'language_select',
     //      '#default_value' => $entity->getUntranslated()->language()->getId(),
     //      '#languages' => Language::STATE_ALL,
     //    );
     return $form;
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\quiz\Entity\Answer */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $question = $entity->getQuestion();
     /* @var $question \Drupal\quiz\Entity\Question */
     $question = $entity->getQuestion();
     /* @var $question \Drupal\quiz\Entity\Question */
     $quiz = $question->getQuiz();
     $status = $quiz->getActiveStatus($this->currentUser());
     /* @var $status \Drupal\quiz\Entity\UserQuizStatus */
     if ($status == NULL) {
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     if ($status->getCurrentQuestionId() != $question->id()) {
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     $count = $question->getUserQuizStateAnswersCount($this->currentUser(), $status);
     if ($count) {
         $status->setLastQuestion($question);
         $status->save();
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->langcode->value, '#languages' => Language::STATE_ALL);
     $form['question'] = array('#type' => 'label', '#title' => $entity->getQuestion()->get('question')->value, '#weight' => -5);
     // Only display a timer if the quiz is timed.
     //kint($quiz->get('time')->value);
     if ($quiz->get('time')->value > 0) {
         $form['timer'] = array('#markup' => '<div id="js-timer"></div>', '#weight' => -9);
         $timeLeft = $quiz->get('time')->value + $status->get('started')->value - time();
         //kint($timeLeft);
         // If we're out of time we mark the status as finished, no matter if some questions were left unanswered.
         if ($timeLeft < 0) {
             $status->setFinished(time());
             $status->setScore($status->evaluate());
             $status->setMaxScore($quiz->getMaxScore());
             $status->setPercent($quiz->get('percent')->value);
             $status->setFinished(time());
             $status->setQuestionsCount(count($quiz->getQuestions()));
             $status->save();
             //TODO: redirect to evaluation. And make status save a separate function in controller.
             return $this->redirect('entity.quiz.canonical', ['quiz' => $quiz->id()]);
         }
         $form['#attached']['library'][] = 'quiz/quiz.timer';
         $form['#attached']['drupalSettings']['quiz']['endtime'] = $timeLeft - 1;
     }
     return $form;
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\rdf_entity\Entity\Rdf */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $type = RdfEntityType::load($entity->bundle());
     if ($type->label()) {
         // Add.
         if ($entity->isNew()) {
             $form['#title'] = $this->t('<em>Add @type</em>', array('@type' => $type->label()));
         } else {
             $form['#title'] = $this->t('<em>Edit @type</em> @title', array('@type' => $type->label(), '@title' => $entity->label()));
         }
     }
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL);
     return $form;
 }
Ejemplo n.º 15
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $entity = $this->entity;
     $state = \Drupal::state();
     $form = parent::buildForm($form, $form_state);
     // Due to #limit_validation_errors, submitting the form with the "Add" button
     // will only expose validated values in the submit handler, so our storage may
     // be incomplete. Therefore, the default values always have to be overloaded.
     $stored_record = $entity->getStorageRecord();
     $stored_record += array('exclude' => '', 'parent' => array('child' => ''), 'field' => array());
     $storage = $form_state->get('mollom_test');
     $storage = empty($storage) ? array() : $storage;
     $stored_record = array_merge($stored_record, $storage);
     // Always add an empty field the user can submit.
     $stored_record['field']['new'] = '';
     $form_state->set('mollom_test', $stored_record);
     // Output a page view counter for page/form cache testing purposes.
     $count = $state->get('mollom_test.view_count', 0);
     $reset_link = \Drupal::l($this->t('Reset'), Url::fromRoute('mollom_test.views_reset', [], ['query' => $this->getDestinationArray()]));
     $form['views'] = array('#markup' => '<p>' . 'Views: ' . $count++ . ' ' . $reset_link . '</p>');
     $state->set('mollom_test.view_count', $count);
     // Conditionally enable form caching.
     if ($state->get('mollom_test.cache_form', FALSE)) {
         $form_state->setCached(TRUE);
     }
     $form['#tree'] = TRUE;
     $form['mid'] = array('#type' => 'hidden', '#value' => $stored_record['mid']);
     $form['title'] = array('#type' => 'textfield', '#title' => 'Title', '#default_value' => $stored_record['title'], '#required' => TRUE);
     $form['body'] = array('#type' => 'textfield', '#title' => 'Body', '#default_value' => $stored_record['body']);
     $form['exclude'] = array('#type' => 'textfield', '#title' => 'Some other field', '#default_value' => $stored_record['exclude']);
     $form['parent']['child'] = array('#type' => 'textfield', '#title' => 'Nested element', '#default_value' => $stored_record['parent']['child']);
     $form['field'] = array('#type' => 'fieldset', '#title' => 'Field');
     $weight = 0;
     foreach ($stored_record['field'] as $delta => $value) {
         $form['field'][$delta] = array('#type' => 'textfield', '#title' => 'Field ' . $delta, '#default_value' => $value, '#weight' => $weight++);
     }
     $form['field']['new']['#weight'] = 999;
     $form['field']['submit'] = array('#type' => 'submit', '#value' => 'Add', '#limit_validation_errors' => array(array('field')), '#submit' => array('::fieldSubmitForm'), '#weight' => 1000);
     $form['status'] = array('#type' => 'checkbox', '#title' => 'Published', '#default_value' => $stored_record['status'], '#access' => \Drupal::currentUser()->hasPermission('administer mollom'));
     return $form;
 }
Ejemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\squad\Entity\Squad */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form_state->setRebuild();
     $form_state->setCached(FALSE);
     // Loading game list
     $game_list = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('game_list');
     $games = array();
     foreach ($game_list as $game) {
         $games[] = $game->name;
     }
     // Loading Squad roles
     $squad_roles = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('team_role');
     $roles = array();
     foreach ($squad_roles as $role) {
         $roles[] = $role->name;
     }
     // Squad Settings
     $form['squad']['name'] = array('#type' => 'textfield', '#title' => 'Squad name');
     $form['squad']['game_list'] = array('#type' => 'select', '#title' => $this->t('Game played by this squad'), '#options' => $games);
     // Players
     $players = $form_state->getValue('players', 1);
     $form['#tree'] = TRUE;
     $form['players'] = ['#type' => 'fieldset', '#title' => $this->t('Squad Members'), '#prefix' => '<div id="players">', '#suffix' => '</div>'];
     if ($players) {
         for ($i = 0; $i < $players; $i++) {
             $form['players'][$i] = array('#type' => 'fieldset', '#tree' => TRUE);
             $form['players'][$i]['name'] = array('#title' => t('Name'), '#type' => 'textfield');
         }
     }
     $form['add_player'] = array('#type' => 'button', '#value' => t('Add a Player'), '#submit' => array('::squad_add_more_callback'), '#ajax' => array('callback' => '::squad_ajax_add_player', 'wrapper' => 'player'));
     $form_state->setValue('players', $players + 1);
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL);
     return $form;
 }
Ejemplo n.º 17
0
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // TODO: Change the autogenerated stub
     $buildForm = parent::buildForm($form, $form_state);
     return $buildForm;
 }
Ejemplo n.º 18
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);

    return $form;
  }