Undefined method getPollDuplicates(); used

Created on 16 February 2024, 4 months ago
Updated 1 March 2024, 4 months ago

Problem/Motivation

See PollForm.php

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $poll = $this->buildEntity($form, $form_state);
    // Check for duplicate titles.
    $poll_storage = $this->entityTypeManager->getStorage('poll');
    $result = $poll_storage->getPollDuplicates($poll);
    foreach ($result as $item) {
      if (strcasecmp($item->label(), $poll->label()) == 0) {
        $form_state->setErrorByName('question', $this->t('A poll named %poll already exists. Enter a unique question.', ['%poll' => $poll->label()]));
      }
    }
    return parent::validateForm($form, $form_state);
  }

Proposed resolution

Check what's wrong or missing.

Remaining tasks

Create a MR.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024