Closed (duplicate)
Project:
Serial Field
Version:
7.x-1.2
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Apr 2012 at 18:52 UTC
Updated:
30 Sep 2013 at 08:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
Randeep.Singh commentedI also got similar kind of error while creating new user. please help and explain..
TYPE php
DATE Monday, October 29, 2012 - 01:31
USER admin
LOCATION http://localhost:8080/website/admin/people/p2rp-create/doctor
REFERRER http://localhost:8080/website/admin/people/p2rp-create/doctor
MESSAGE PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'nid' cannot be null: INSERT INTO {serial_doctor_field_serial} (nid) VALUES (:db_insert_placeholder_0); Array ( [:db_insert_placeholder_0] => ) in _serial_generate_value() (line 155 of C:\wamp\www\website\sites\all\modules\serial\serial.inc).
SEVERITY error
HOSTNAME 127.0.0.1
OPERATIONS
Comment #2
ytsejam commentedUnfortunately I have the same problem.
Comment #3
BParticle commentedSame kind of error when adding a Serial field to an entityform submission
I'm not a php expert, but this error probably just points to the fact that both profiles and entityform submissions don't have a NID, as profiles have UID's and submissions of an entityform share the same NID of the parent node.
Just for testing purposes I changed line 83
$sid = _serial_generate_value($entity->nid, $instance['bundle'], $field['field_name']);into
THIS IS NOT A SOLUTION BY FAR (like I said, I'm not a php person), so please don't replicate. However monstrous and unorthodox, it made saving the entityform submission possible (giving me a different error though), and it made a nice Serial ID as a result. Anyone who knows what he's doing should be able to provide a patch with this information I think.
Comment #4
cthos commentedSomething like this might do the trick?
It's a little profile2 specific though, so I'd be open to suggestions on how to make it a bit more friendly? Maybe some sort of module invokation to get the appropriate value? The bad news is $entity isn't always a type of Entity, sometimes it is StdClass.
Anyhow, patch!
Comment #5
cthos commentedChanging status to needs review.
Comment #6
hoporr commentedI had the same problem twice now:
1) tried to attach a serial field to the user account. Of course, users don't nids.
2) Then tired to attach the field to the profile. There again, profiles don't have nids.
Seems the code is written to only be able to attach to node CTs.
To make this more general a fix, the check should be made against the entity-key. You can grab that out of the entity_info defintion, and then write a more general test against. Then it should work for any entity.
Comment #7
hoporr commentedRaising the status on to critical, as it probably prevents this field/module to be used on any entity besiders node. That is a major show stopper.
Comment #8
hoporr commentedI found that this is a duplicate of https://drupal.org/node/1333032 "Add generic entity support"
If the general issue (entity) is solved, then this case here will work as well.