I would like to insert a nodereference autocomplete field in a form on a module I am writing. It is working with the exception of being able to specify the field length. My code is below. I just need to figure out how to set the field length.

        $form['quick_ticket']['user'] = array(
          '#type' => 'nodereference_autocomplete',
          '#title' => 'User',
          '#default_value' => variable_get('module_var', NULL),
          '#autocomplete_path' => 'nodereference/autocomplete/field_user',
          '#field_name' => 'field_user',
          '#description' => 'Description',
          '#size' => 25,
        );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tms8707056’s picture

BTW, '#size' => 25, does not work. I just forgot to take it out.

mlncn’s picture

Category: support » bug
Issue tags: +Science Collaboration

Same issue. Why don't nodereference fields allow their width to be changed? On the HTML level, they are a an input type "text" with a size attribute, but that seems hardcoded at 60 right now.

benjamin, Agaric Design Collective

mlncn’s picture

Title: Nodereference field size in custom form. » Allow Nodereference autocomplete field size to be changed
Version: 6.x-2.3 » 6.x-2.x-dev
Assigned: Unassigned » mlncn
Category: bug » feature
Status: Active » Needs review
FileSize
1.46 KB
mlncn’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Component: Code » nodereference.module

Sorry-- I didn't notice this issue was originally filed in entirely the wrong queue until I went to check on it and couldn't find it. This is a CCK issue, not Views!

The above patch will apply from the root of the CCK directory, making a change to nodereference.module.

benjamin, Agaric Design Collective

tms8707056’s picture

The patch works great.

mlncn’s picture

Status: Needs review » Reviewed & tested by the community
yched’s picture

Status: Reviewed & tested by the community » Fixed

Transposed to userref autocomplete widget, and committed. Thanks !

mlncn’s picture

Great! Transposed means "in addition"?

yched’s picture

Yes. I considered committing it to userref only as a kind of sick joke, but eventually changed my mind ;-)

mlncn’s picture

LOL!

markus_petrux’s picture

Status: Fixed » Needs review
FileSize
1 KB

Sorry to bump this issue, but the fix to userreference is not completely correct, I'm afraid.

Attached patch fixes it.

yched’s picture

Status: Needs review » Fixed

True, fixed. Thanks Markus ! Er, that's twice in 10 days...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tms8707056’s picture

This doesn't seem to be working in the latest dev version released yesterday.