- Issue created by @acast
Unique content field validation not working
I need a text field in my drupal database to be unique and install this----> module composer require 'drupal/unique_content_field_validation:^1.1'
Once installed, when I want to create another Device with the same serial number, it lets me do it and I don't get any errors.
I don't know if the problem has more to do with the database itself or the installation of the module. It should not allow you to create a device with the same serial number.
Tables in SQL:
Not changes after setting the field as unique.
DROP TABLE IF EXISTS `node__field_device_serial_number`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `node__field_device_serial_number` (
`bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
`deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted',
`entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
`revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to',
`langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
`delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
`field_device_serial_number_value` varchar(255) NOT NULL,
PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
KEY `bundle` (`bundle`),
KEY `revision_id` (`revision_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for node field field_device_serial_number.';
/*!40101 SET character_set_client = @saved_cs_client */;
*I leave images below
Active
1.1
Code