예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     $entity = parent::validateForm($form, $form_state);
     if ($entity->isNew()) {
         //      $exists = $this->entityStorage->loadByProperties(array('info' => $form_state->getValue(['info', 0, 'value'])));
         if (!empty($exists)) {
             $form_state->setErrorByName('info', $this->t('A @entity_label with description %name already exists.', ['@entity_label' => $this->entity->label(), '%name' => $form_state->getValue(['info', 0, 'value'])]));
         }
     }
     return $entity;
 }
 /**
  * Provides the page title for this controller.
  *
  * @param \Drupal\content_entity_base\Entity\EntityBaseInterface $entity_definition
  *   The custom entity type to add.
  * @param string $action
  *   The action being performed.
  *
  * @return string
  *   The page title.
  */
 public function getEntityFormTitle(EntityBaseInterface $entity_definition, $action = 'default')
 {
     return $this->t('@action %type @entity_label', ['@action' => ucwords(strtolower($action)), '@entity_label' => $entity_definition->label(), '%type' => $entity_definition->label()]);
 }