I have following issue:

I use following PHP Code to generate a number with the Serial module

$entity_field[0]['value'] = str_pad($field->field_serial [LANGUAGE_NONE] [0]['value'], 6, '0', STR_PAD_LEFT);

I have no errors in the Drupal log but it generates only sometimes the Number. I my database it saves only 000000. I use the varchar data type. In the token of the title it shows me sometimes the correct number/value but after resaving the node all is again on 000000. What make i wrong? Can anyone help me?

I want use the Number/Field later as Token for URL and Title.

CommentFileSizeAuthor
computed-field-settings.JPG77.38 KBalexander.sibert

Comments

zwerg’s picture

Issue summary: View changes

+1, same issue

zwerg’s picture

Status: Active » Closed (fixed)

Found a solution:

computed code:

$entity_field[0]['value'] = $entity->field_serial[LANGUAGE_NONE][0]['value'];

display code:

$display_output = str_pad($entity_field_item['value'], 4, '0', STR_PAD_LEFT);

If you want to use it for auto-sku in shopping systems you have to check the "computed" pattern.