We use the latest amfphp to load and save nodes from a flex application. Unfortunatelly node references and user references which are loaded correctly are not set after saving the node from flex. Another cck text field gets updated correctly.

The content type is set up as follows:
Editor field_editor User Reference
Journal field_journal Node Reference
JournalStructure field_journalstructure Text

The node before the update:
Editor
Editor
Journal
eJournal - Das Team
JournalStructure
<?xml version="1.0" encoding="UTF-8"?> äöü

The node after the update:

Editor
Journal
JournalStructure
<?xml version="1.0" encoding="UTF-8"?> äöü

The code in flex:

private function getRelease() : void {
this.node_load.load(this.releaseNodeId);
}

public function onLoaded(event:ResultEvent):void {
this.release = event.result;
this.journalStructure = release.field_journalstructure[0].value;
}

private function saveStructure() : void {
release.field_journalstructure[0].value = textarea.text;
node_save.save(release);
}

I checked in the flex debugger that the values in the release object are set before I call save. Seems to get lost somewhere further down.
Any hints where to investigate further are welcome!

Kind regards
Uwe

Comments

uwej’s picture

I realized now that only fields supplied during save are updated, so I have a workaround for this problem. Anyway If somebody knows a solution that would be great.

cdraptor’s picture

I may be able to help. Here is what I found

Doing a node load on a CCK int field that I have in one of my nodes

[field_placeid] => Array
(
[0] => Array
(
[value] => 9
)

What I did to save this in Flex is:

var edit:Object = new Object;

var fromDate:Date = new Date(2007,10,10,5,0,0,0);
var toDate:Date = new Date(2007,10,10,6,0,0,0);

edit.type = "event";
edit.title = "HELP ME";
edit.body = "trying to get the event times to save - why doesn't it";

edit.uid = 2;
edit.name = "cdurham";

// Here I set edit.(field_placeid) my CCK field, then I create a new Array with "value" assoc array to 9, worked wonderful
edit.field_placeid = new Array({value:9});

//some data I wanted to leave empty, maybe this isn't needed
edit.field_time = new Array();
edit.locations = new Array();
edit.location = new Array();

Hope this helps

eventnode.save(edit);

dsgirard’s picture

awesome, exactly what I was looking for!

snelson’s picture

Category: bug » support
Status: Active » Closed (fixed)
leoman_730’s picture

Have you tried to save another type of cck field? Such as select field, I am using the same method as describe above, I was able to save any cck textfield, but that not work for any select field.
Any idea?

bigbaykiter’s picture

I am also trying to save a 'select field' ? no luch either :(

alan d.’s picture

Node references probably need nid instead of value/ User references uid.Otherwise the array is the same.

I have not tested this so report back if it works or crashes badly ;]

seanmclucas’s picture

Yeah I'm still having an issue with dynamically creating nodes that have cck fields with radio buttons, check, boxes, multi-select lists, etc. Node reference CCK fields don't work since they are a multi-select list in this case.

//create a new patient-study-record node
$studyRecordNode = new stdClass();
$studyRecordNode->title = $nTitle . ' - ' . $patientNode->title;
$studyRecordNode->field_site_reference[]['value'] = $siteNid;              //Node Reference	
$studyRecordNode->field_study_reference[]['nid'] = $studyNid;            //Node Reference	
$studyRecordNode->field_status_reference[]['value'] = 360;  		 //Node Reference 	
$studyRecordNode->uid = 1;
$studyRecordNode->type = 'patient_study_record';
$studyRecordNode->status = 1;
$studyRecordNode->promote = 0;  
$node = node_submit($studyRecordNode);
node_save($node);

Of course the title, type, status, etc work. None of the CCK fields do if they are a select-list or checkboxes, etc. Plain text CCK fields import just fine.

I even tried things like "nid" instead of "value" but that didn't work either.

josys64’s picture

Title: amfphp: node.save and cck node reference and user reference » amfphp: node.get views and cck
Version: 5.x-1.x-dev » 6.x-0.13
Status: Closed (fixed) » Active

Hi everybody,

I try desperatly to fix an issue from my installation.

i can't get all data from my view, especially CCK field:
- view name : "recipes_all" and i get these data when i test in Drupal services :

Array
(
[0] => stdClass Object
        (
            [nid] => 9
            [node_title] => La tarte aux oursins
            [node_revisions_body] => des oursins bien mûrs
            [node_revisions_format] => 1
            [node_data_field_photo_field_photo_fid] => 
            [node_data_field_photo_field_photo_list] => 
            [node_data_field_photo_field_photo_data] => 
            [node_data_field_photo_nid] => 
            [node_type] => recipe
            [node_data_field_photo_field_toto_value] => test
            [node_status] => 1
        )
)

In flex (for my test i didn't specify any field):


public function getRecipes():void
{  
  views.get("recipes_all");    
}
public function onViewsResult(event:ResultEvent):void
{
  trace(ObjectUtil.toString(event.result));	
  recipes = ArrayUtil.toArray(event.result);
 }

and trace show me this :

(Array)#0
  [0] (Object)#1
    nid = "9"
    node_revisions_body = "des oursins bien murs"
    node_revisions_format = "1"
    node_status = "1"
    node_title = "La tarte aux oursins"

if someone have any idea ?

thanks

Johannes De Boeck’s picture

josys64’s picture

Status: Active » Fixed

yes, it's worked fine.
thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.