You are here

function multi_node_widget_form in Multi Node Add 6

Generate the input widgets.

1 call to multi_node_widget_form()
multi_node_add_frame in ./multi_node_add.module
Presents the node creating row form.

File

./multi_node_add.module, line 252
This module allows to create multiple nodes using one page, one form submission. Uses AJAX.

Code

function multi_node_widget_form($type, $fields_show) {
  $form = array();
  $fields = array();
  if (function_exists('content_fields')) {
    $fields = content_fields();
  }
  $fields += _multi_node_add_non_cck_fields($type);

  // Generate taxo widgets if any
  $temp_form = array();
  $form_state = array();
  $temp_form['#node'] = new stdClass();
  $temp_form['#node']->type = $type;
  $temp_form['type']['#value'] = $type;
  taxonomy_form_alter($temp_form, $form_state, $type . '_node_form');
  $fields['taxonomy'] = array();
  if (is_array($temp_form['taxonomy'])) {
    unset($temp_form['taxonomy']['#weight']);
    foreach ($temp_form['taxonomy'] as $k => $v) {
      if (is_array($temp_form['taxonomy'][$k])) {
        unset($temp_form['taxonomy'][$k]['#weight']);
      }
    }
    $fields['taxonomy']['field_def']['taxonomy'] = $temp_form['taxonomy'];
  }
  foreach ($fields_show as $field_name) {
    if (isset($fields[$field_name])) {
      $field = $fields[$field_name];
      if (isset($field['field_def'])) {

        // is it our hacked definition?
        $field_def = (array) $field['field_def'];
      }
      else {

        // no, it's CCK
        $form_a['fields'] = array(
          '#type' => 'value',
          '#value' => array(
            $type,
          ),
        );
        $form['#field_info'][$field_name] = $field;
        $form_state = array();
        $field_def = (array) content_field_form($form, $form_state, $field);
      }
      $form += $field_def;
    }
  }
  return $form;
}