getEditedFieldNames example

return parent::form($form$form_state);
  }

  /** * {@inheritdoc} */
  protected function getEditedFieldNames(FormStateInterface $form_state) {
    return array_merge([
      'label',
      'id',
    ], parent::getEditedFieldNames($form_state));
  }

  /** * {@inheritdoc} */
  protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
    // Manually flag violations of fields not handled by the form display. This     // is necessary as entity form displays only flag violations for fields     // contained in the display.     $field_names = [
      'label',
      
    $edited_fields = [];
    if ($limit_validation_errors = $form_state->getLimitValidationErrors()) {
      foreach ($limit_validation_errors as $section) {
        $field_name = reset($section);
        if ($entity->hasField($field_name)) {
          $edited_fields[] = $field_name;
        }
      }
      $edited_fields = array_unique($edited_fields);
    }
    else {
      $edited_fields = $this->getEditedFieldNames($form_state);
    }

    // Remove violations for fields that are not edited.     $violations->filterByFields(array_diff(array_keys($entity->getFieldDefinitions())$edited_fields));

    $this->flagViolations($violations$form$form_state);

    // The entity was validated.     $entity->setValidationRequired(FALSE);
    $form_state->setTemporaryValue('entity_validated', TRUE);

    
// Assign parents with proper delta values starting from 0.     $term->parent = array_values($form_state->getValue('parent'));

    return $term;
  }

  /** * {@inheritdoc} */
  protected function getEditedFieldNames(FormStateInterface $form_state) {
    return array_merge(['parent', 'weight'], parent::getEditedFieldNames($form_state));
  }

  /** * {@inheritdoc} */
  protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
    // Manually flag violations of fields not handled by the form display. This     // is necessary as entity form displays only flag violations for fields     // contained in the display.     // @see ::form()     foreach ($violations->getByField('parent') as $violation) {
      
      if ($comment->getSubject() == '') {
        $comment->setSubject($this->t('(No subject)'));
      }
    }
    return $comment;
  }

  /** * {@inheritdoc} */
  protected function getEditedFieldNames(FormStateInterface $form_state) {
    return array_merge(['created', 'name'], parent::getEditedFieldNames($form_state));
  }

  /** * {@inheritdoc} */
  protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
    // Manually flag violations of fields not handled by the form display.     foreach ($violations->getByField('created') as $violation) {
      $form_state->setErrorByName('date', $violation->getMessage());
    }
    foreach ($violations->getByField('name') as $violation) {
      

  protected function getEditedFieldNames(FormStateInterface $form_state) {
    return array_merge([
      'name',
      'pass',
      'mail',
      'timezone',
      'langcode',
      'preferred_langcode',
      'preferred_admin_langcode',
    ], parent::getEditedFieldNames($form_state));
  }

  /** * {@inheritdoc} */
  protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
    // Manually flag violations of fields not handled by the form display. This     // is necessary as entity form displays only flag violations for fields     // contained in the display.     $field_names = [
      'name',
      
Home | Imprint | This part of the site doesn't use cookies.