Not working when nodes created programmatically | New version

Created on 19 May 2021, about 3 years ago
Updated 11 April 2023, about 1 year ago

Problem/Motivation

I am trying to import some nodes programmatically. The modules do not work for programmatic node creation.

Steps to reproduce

  1. Add Validation on any node field using this module
  2. Create this node using UI with duplicate value
  3. You will be able to see the validation error
  4. Create this node programmatically
  5. You will not be able to see the validation error and the node with duplicate values will be created

Proposed resolution

The approach used as of now is using the hook_form_alter. We can use drupal constraints here for validation.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India mehul.shah

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy kopeboy Mainland

    Any update? 🙏🏻

    Maybe it's related so I let you know that this module doesn't work with editablefields too:

    When trying to edit a unique field inside a View (using "Editable Field" formatter), other modules' defined validations on the same field work (for example machine_name), but the one provided by this module throws a silent php error:
    Error: Call to undefined method Drupal\editablefields\Form\EditableFieldsForm::getEntity() in unique_content_field_validation_validate_unique() (line 232 of /var/www/html/web/modules/contrib/unique_content_field_validation/unique_content_field_validation.module).

  • 🇪🇸Spain selvira Seville, Spain 🇪🇸, UTC+2 🇪🇺

    Hi @kopeboy I think this could help you:
    https://www.drupal.org/project/unique_content_field_validation/issues/33... 🐛 Bulk operation not working on nodes. Fixed check the patch I uploaded maybe it solves your problem because I got the same error as you previously.

    Greetings.

  • Assigned to fabiansierra5191
  • Status changed to Active about 1 year ago
  • 🇨🇴Colombia fabiansierra5191

    FYI, I started to work on version 2.X, for now, the changes include:
    - Use Drupal Constraints for validation
    - Plugin system to create/add custom fields to the validation

    So, I take this ticket to follow up and communicate things regarding the new version

  • 🇪🇸Spain selvira Seville, Spain 🇪🇸, UTC+2 🇪🇺

    Thank you Fabian.
    Best.

Production build 0.69.0 2024