I created a custom content type, and hid the the 'title' field. Everything went fine, until I tried to submit the new node of that newly created content type, obviously without the title (I hid the field in the 'manage form display').
DB Error as reported from logs:
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null: INSERT INTO {node_field_data} (nid, vid, type, langcode, title, uid, status, created, changed, promote, sticky, revision_translation_affected, default_langcode, ds_switch) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13); Array ( [:db_insert_placeholder_0] => 11 [:db_insert_placeholder_1] => 11 [:db_insert_placeholder_2] => testimonial [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => 1456957777 [:db_insert_placeholder_8] => 1456957782 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => 1 [:db_insert_placeholder_13] => ) in Drupal\Core\Database\Connection->handleQueryException() (line 673 of /Users/micahjoyner/www/cmm.dev/core/lib/Drupal/Core/Database/Connection.php).
Page Error after submitting node without title:
The website encountered an unexpected error. Please try again later.
I don't think this is a duplicated issue, but it is related to:
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Creating-titleless-node-2679907-3-8.patch | 541 bytes | ajalan065 |
Comments
Comment #2
therealssj commentedI suppose we have 2 options here:
1) Not allow required fields to be hidden in manage form display.
2) When saving the data check whether required field are hidden and if they are set their value as null.
1) This seems to be erroneous as pointed out in this https://www.drupal.org/node/2358537
Thus second seems to be a viable option.
Comment #3
ajalan065 commentedI have changed the default requirement for the title.
Hope the patch solves your purpose.
Comment #4
ajalan065 commentedI have changed the default requirement for the title.
Hope the patch solves your purpose.
Comment #5
therealssj commented@ajalan065 The patch would only work if you set up a clean build of drupal or somehow rebuild the database.3
Also i get a permission warning when applying that patch.
Comment #7
ajalan065 commented@therealssj, can you please attach a screenshot of the permission you are being asked?
And, I tested the patch on my local(without a clean install). Try clearing your cache.
Comment #8
swentel commentedThis is partically a duplicate of #2567899: Empty node titles cause failures when migrating because empty strings are treated as NULL (but a bit more cryptic) and #2111443: Show a warning when configuring form displays when a field is hidden and has no default value.
Comment #9
justinlevi commentedIf I were to create a custom module, where would I hook into the save process to give the title a default value, say the current date/time?
Never mind - found the hook
Is there a better way to do this in D8?