Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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,
);
Comment | File | Size | Author |
---|---|---|---|
#11 | userreference-size.patch | 1 KB | markus_petrux |
#3 | nodereference-add-field-size-to-autocomplete-399778-3.patch | 1.46 KB | mlncn |
Comments
Comment #1
tms8707056 CreditAttribution: tms8707056 commentedBTW, '#size' => 25, does not work. I just forgot to take it out.
Comment #2
mlncn CreditAttribution: mlncn commentedSame 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
Comment #3
mlncn CreditAttribution: mlncn commentedComment #4
mlncn CreditAttribution: mlncn commentedSorry-- 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
Comment #5
tms8707056 CreditAttribution: tms8707056 commentedThe patch works great.
Comment #6
mlncn CreditAttribution: mlncn commentedComment #7
yched CreditAttribution: yched commentedTransposed to userref autocomplete widget, and committed. Thanks !
Comment #8
mlncn CreditAttribution: mlncn commentedGreat! Transposed means "in addition"?
Comment #9
yched CreditAttribution: yched commentedYes. I considered committing it to userref only as a kind of sick joke, but eventually changed my mind ;-)
Comment #10
mlncn CreditAttribution: mlncn commentedLOL!
Comment #11
markus_petrux CreditAttribution: markus_petrux commentedSorry to bump this issue, but the fix to userreference is not completely correct, I'm afraid.
Attached patch fixes it.
Comment #12
yched CreditAttribution: yched commentedTrue, fixed. Thanks Markus ! Er, that's twice in 10 days...
Comment #14
tms8707056 CreditAttribution: tms8707056 commentedThis doesn't seem to be working in the latest dev version released yesterday.