Hello

next code automatic create node

$node = array('type' => 'place');
$values['title'] = $name;
$values['body'] = $description;
$values['filed_place'] = $place
$values['name'] = "admin";
$s = drupal_execute('place_node_form', $values, $node);

filed_place defined by CCK. Node was created, but field_place not set. What the problem?

vovan

Comments

4wding’s picture

Are the other fields in the form set correctly?

If this code is a snippet from your actual site, there are a couple of errors on the line in question.

  • Spelling of filed_place and field_place needs to be consistent
  • You need a ; at the end of the line
vovan’s picture

filed_place - error. Thanks

I replace filed_place by field_place. Now when i write to field_place value "743", there is "7". Only first simbol.

pielgrzym’s picture

You misspelled 'field' in your code :)

First of all put a
var_dump($node);

in your node.tpl.php, go to you cck node and check the actual field name. Usually cck fields have a nested array (even if they accept only one value) with key 'value' (and some others). I would try:

$values['field_place'][0]['value'] = $place

If this doesn't work, take a peek at what var_dump produces and experiment (or paste here). Wouldn't it be easier to pass all the data in the node object anyway? :)

--
Pielgrzym

vovan’s picture

It work, Thanks.

function importload_write_node($name,$place,$description) {
	$node = array('type' => 'place'); 
	$values['title'] = $name; 
	$values['body'] = $description;
	$values['field_place'] = Array(Array("value"=>$place));
	$values['path'] = $place;
	$values['name'] = "admin";
	$values['menu'] = Array("title" => $name, "pid" => 57);
	$s = drupal_execute('place_node_form', $values, $node);
}

Drupal fareva!!!