Hello,

I'm working on converting an existing 4.6.x site to 5.1, and I'm trying to use the CCK group of modules instead of my own cobbled-together code like I did last time. I'm trying to set up a content type, and I've run into a problem with the node_reference field type.

Basically, I need to use the auto complete text field type, and I will need multiple values, but when I select those options, I only get three autocomplete text boxes. I'm going to need as many as 15 or 20 in some cases, but usually more like 4 or 5. Is there any way to add more boxes? It seems it would be pretty easy (from an interface point of view) to have a "add more" button that would insert an extra three fields when clicked.

I'm writing this here because I'm hoping it's something already built in that I've overlooked, but if not, this seems like a pretty logical feature to request.

Thanks in advance for any suggestions.

Comments

nevets’s picture

If you use all 3 save the form and re-edit, more autocomplete fields will be added (it appears there are always 3 free inputs each time you edit)

zwhalen’s picture

Ok, I thought it was something like that -- and it does work. Thanks!

It creates an unusual work flow, however, and it seems like it would make more sense if the extra fields appeared when you preview the node. It just seems awkward, especially for node types that default to "published" and the front page, to have publish it multiple times before it's complete. Does this make sense to anyone else? I'm curious enough about it to start looking through the module code to see if I can figure out what would need to be changed.

matt_paz’s picture

I agree ... it would definitely be desirable to modify this to create a more effective worfklow/ui

Mojah’s picture

foxtrotcharlie’s picture

I've added more using a form_alter:

function your_helper_form_alter($form_id, &$form) {
  if ($form_id == "paper_node_form") {
  	$field_name = 'field_refers_to_author';
		$number_of_fields = 6;
		$start = 1;
		$form[$field_name]['#type'] = 'fieldset';
		$form[$field_name]['#description'] = content_filter_xss(t('Please select one or more authors. If the author does not appear in this list, please add them first.'));		
    foreach (range($start, $number_of_fields) as $field_number) {
      $form[$field_name][$field_number]['node_name'] = array(
        '#type' => 'textfield',
        '#title' => '',
        '#autocomplete_path' => 'nodereference/autocomplete/'. $field_name,
        '#default_value' => '',
        '#required' => FALSE,
      );
    }  	
  }
} // function your_helper_form_alter

There's still some hard-coding here in terms of the field name and description, but at least it's not hacking the nodereference.module itself.

Charles

www.parkroad.co.za