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:

https://www.drupal.org/node/2358537

Comments

cheeky-micah created an issue. See original summary.

therealssj’s picture

I 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.

ajalan065’s picture

StatusFileSize
new541 bytes

I have changed the default requirement for the title.
Hope the patch solves your purpose.

ajalan065’s picture

Status: Needs work » Needs review

I have changed the default requirement for the title.
Hope the patch solves your purpose.

therealssj’s picture

@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.

Status: Needs review » Needs work

The last submitted patch, 3: Creating-titleless-node-2679907-3-8.patch, failed testing.

ajalan065’s picture

@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.

justinlevi’s picture

If 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

function MODULE_node_presave($node)
{
    $node->title = date("F j, Y, g:i a");
}

Is there a better way to do this in D8?