[development] new form api: dates works?

Fabio Varesano fabio.varesano at gmail.com
Mon Dec 12 15:52:28 UTC 2005


Hi everybody!

I'm developing a module were I need to
store a date inserted by the user who create
the new node type.
The problem is that I can't use the date
inserted by the user... I just get a '1' instead
of a formatted data or an integer representing dates.

Is this date api working?
Or maybe I'm doing things not good?


My function looks like this:

function goods_request_form(&$node,  &$param) {
...

$form['closing_date'] = array(
    '#type' => 'date',
    '#title' => t('closing date'),
    '#default_value' => $node->closing_date,
    '#description' => t('Insert here the date were the request will be
closed'),
    '#required' => TRUE,
    '#weight' => -1
  );

....
}

function goods_request_insert($node) {
  print_r($node); die();
  db_query('INSERT INTO {goods_request} (nid, vid, tid, closing_date,
shipping_address) VALUES (%d, %d, %d, %d, %s)', $node->nid, $node->vid,
$node->tid, $node->closing_date, $node->shipping_address);
}

the debugging putput of the print_r is
stdClass Object ( [nid] => 6 [vid] => 6 [uid] => 1 [created] =>
1134402069 [changed] => 1134402709 [type] => goods_request [title] =>
aaa [body] => aaa [closing_date] => 1 [shipping_address] => aaa [name]
=> administrator [date] => 2005-12-12 15:41:09 +0000 [status] => 1
[moderate] => 0 [promote] => 1 [sticky] => 0 [revision] => 0 [preview]
=> Preview [submit] => Submit [form_id] => goods_request_node_form
[comment] => 2 [menu] => Array ( [title] => [description] => [pid] => 1
[path] => [weight] => 0 [mid] => 0 [type] => 86 ) [teaser] => aaa
[validated] => 1 [is_new] => 1 )


Thanks

Fabio



More information about the development mailing list