I’m trying to insert values for a node field from a custom module. The value will only be inserted from that module and then no operation for that node will be performed, so hook is not in my consideration. I’ve tried to directly insert values to the field_data_… and field_revision_… tables. but I’ve found that drupal also saves the values (serialized) in field_config and field_config_instance tables as blob. since I’m only inserting values in two tables drupal is not reading values I’ve inserted for nodes. I couldn’t understand the serialization stored in DB. so I’m searching for a method that will help me to insert values through API or any other neat way.
any help on the thing I’m trying to accomplish would be great. Thank you
EDIT:
after taking look at serialized content of field_config table I understood that the serialized data is just field configuration and get inserted into the table on first save. My problem solved by saving the first value through admin/content and now my direct DB inserted data is available to the node. this is the serialized data I’ve got:
a:7:
{s:12:"translatable";
s:1:"0";
s:12:"entity_types";
a:0:{}
s:8:"settings";
a:3:
{s:9:"precision";
s:2:"10";s:5:"scale";
s:1:"2";
s:17:"decimal_separator";
s:1:",";
}
s:7:"storage";
a:5:
{s:4:"type";
s:17:"field_sql_storage";
s:8:"settings";
a:0:{}
s:6:"module";
s:17:"field_sql_storage";
s:6:"active";
s:1:"1";
s:7:"details";
a:1:
{s:3:"sql";
a:2:
{s:18:"FIELD_LOAD_CURRENT";
a:1:
{s:22:"field_data_field_total";
a:1:
{s:5:"value";
s:17:"field_total_value";
}
}
s:19:"FIELD_LOAD_REVISION";
a:1:
{s:26:"field_revision_field_total";
a:1:
{s:5:"value";
s:17:"field_total_value";
}
}
}
}
}
s:12:"foreign keys";
a:0:{}
s:7:"indexes";
a:0:{}
s:2:"id";
s:2:"34";
}
Hope this will help you.