Closed (fixed)
Project:
TableField
Version:
7.x-2.2
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2014 at 10:54 UTC
Updated:
24 Oct 2017 at 01:40 UTC
Jump to comment: Most recent
Comments
Comment #1
carlovdb commentedHave you succeeded this?
Comment #2
nimek commentedYes
All you must do is properly indexed array:
$yourtable = array(
'col_0_0' => $value0_0,
'col_0_1' => $value0_0
);
where col_0_X index will be used as header.
then
$node->field_tablefield_name['und'][0]['value'] = serialize($yourtable);
and node_save($node) of course
All the best :)
Comment #3
carlovdb commentedHmm this is not directly what I need I think.
This is my problem.. https://drupal.org/node/2235751
Comment #4
kalabroApproach in #2 looks quite dirty. I also have to add 'rebuild' key to get rid of PHP Notices.
Why not add Entity API's 'property_callbacks' so we can set value simply:
I'm ready to provide a patch if the idea someone find it interesting.
Comment #5
oenie commentedI think this oatch would be very welcome.
I can't imagine the worold without entity_metadat_wrapper, but it's a bit silly having to access one of the fields the 'old' way with array indexing.
Comment #6
mchelen@kalabro
A patch to add a callback would be great! Entity metadata wrapper seems to work with most other field types, but not Tablefield.
Here is a full working example using the approach from #2, note that "col" is supposed to be "cell":
In this case I am editing
field_mytablefieldin node 1.I still get a warning:
array_flip(): Can only flip STRING and INTEGER values!But the node seems to be working ok.
Comment #7
lolandese commentedThis seems to be answered sufficiently. Feel free to reopen if not.
Comment #9
xelat commentedI'm getting this error using the code in #2 or 6.
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7929 of C:\Users\ssaata\Documents\websites\docgen\includes\common.inc).The error is coming from
node_save();.I'm using Table field 7.x-3.1 and core 7.56. Is there any code I need to update to get that version to work?
EDIT on 24/10/2017 2:57pm
I updated this line and the error is gone
EDIT on 25/10/2017 4:54pm
This is the syntax for tablefield 7.x-3.1