Posted by agalligani on February 9, 2013 at 7:10am
I have a node type called 'destination' and a view that shows destination nodes. The view works if I go through as admin and "create content" for a destination. But when I create a node using my module using a form no dice.... not in the view. No filter criteria exists in the view other than the node type of course.
Here is the submit hook for the form submit. It must be an obvious problem.
function trip_planner_submit($form, &$form_state) {
drupal_set_message($form_state['values']['trip_nid'].' - '.$form_state['values']['dest_lat']." : ".$form_state['values']['dest_lng']);
global $user;
$node = new stdClass();
$node->type = "destination";
$node->title = $form_state['values']['location_name'];
$node->created = time();
$node->changed = $node->created;
//set field values
$node->field_trip_number['und'][0]['value'] = $form_state['values']['trip_nid'];
// using the location module - mostly dummy data for now
$location = array(
'lid' => NULL,
'name' => $form_state['values']['location_name'],
'street' => '123',
'additional' => '',
'city' => '',
'province' => '',
'postal_code' => 99999,
'country' => 'US',
'latitude' => (float) ($form_state['values']['dest_lat']),
'longitude' => (float) ($form_state['values']['dest_lng']),
'source' => LOCATION_LATLON_GEOCODED_APPROX,
'inhibit_geocode' => TRUE,
);
$settings = variable_get('location_settings_node_' . $node->type, array());
$location['location_settings'] = $settings;
$node->locations[] = $location;
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1; //(1 or 0): published or not
$node->promote = 0; //(1 or 0): promoted to front page
$node->comment = 1; //2 = comments on, 1 = comments off
$node = node_submit($node); // Prepare node for saving
node_save($node);
//drupal_set_message( "Node with nid " . $node->nid . " saved!\n");
$form_state['redirect'] = 'tripper/'.$form_state['values']['trip_nid'];
}
Comments
nevermind
looks like I must have done something weird creating the view. i just created a new one and it works just fine...
Drupal 7.0