0

drupal 7 の datetime フィールドにデータを追加する必要があります。

$node->field_test_a_updated[0]['value'] = $val;
$node->field_test_a_updated[0]['delta'] = 0;
$node->field_test_a_updated[0]['timezone'] = 'UTC';
$node->field_test_a_updated[0]['timezone_db'] = 'UTC';
$node->field_test_a_updated[0]['date_type'] = 'datetime';

$val の値は "2010-06-15T00:00:00-00:00" です。

コンテンツをインポートしようとすると、日付フィールドを除いて、ノードに関連付けられている他のすべてのフィールドが適切に移行されます。[LANGUAGE_NONE] オプションも使用してみました。

drupal7 フィールド API に関連する何かが欠けていると確信しています。

助けてください。

4

1 に答える 1

0

Drupal 7 のフィールドの構造 (この文脈では) は次のとおりです。

array(
  'language_code' => array(
    0 => array(
      'value => $val,
      'other_column_value' => $other_val
    )
  )
);

内部のdelta各配列のキーによって処理される$array['language_code']ため、含める必要はありません。あなたの場合、コードを次のようにしたいです(もちろん、node_save()後でノードを渡すと仮定します):

$node->field_test_a_updated[LANGUAGE_NONE] = array(
  0 => array(
    'value' => $val,
    'timezone' => 'UTC',
    'timezone_db' => 'UTC',
    'date_type' => 'datetime'
  )
);

それが役立つことを願っています

于 2011-09-07T09:52:15.190 に答える