Hello Guys,

I have found a bug with maximum length for autocomplete fields on coupon edit page on 'Applicable products' fieldset (admin/store/coupons/2/edit for example). Based on what I saw in code it should be 255 symbols (in uc_coupon.admin.inc line 557).

    $form['products'][] = array(
      '#type' => 'textfield',
      '#default_value' => $title .' [nid:'. $nid .']',
      '#autocomplete_path' => 'admin/store/coupons/autocomplete/node',
      '#maxlength' => 255,
    );

But actual length is 128 only. I have some titles on my web-site which are even more than 255, so would be great to remove this option

'#maxlength' => 255,

And if you want to leave max length - I have found place where you can put 255 - its same file and line 666 - just add maxlenght info there (this code replace code from 557):

      $form[$field][] = array(
        '#type' => 'textfield',
        '#autocomplete_path' => $path ? $path : NULL,
      );

Thanks,
Vadim

Comments

wodenx’s picture

Status: Active » Fixed
StatusFileSize
new1.2 KB

The default #maxlength for textfields is 128, so if we don't specify a max length that's what we get. The first code snippet you quoted is for titles that have already been specified; the second is for blank fields to add new titles. In both cases, we need to set the #maxlength. I don't think you can have titles >255 chars since that's the length of that column in the schema - but I did realize that only allowing 255 characters for the autocomplete won't work because we append the [nid=%] - so i've increased the maxlength to 300 in both places, and for taxonomy terms. That fix is committed to DEV, and attached here as a patch.

Status: Fixed » Closed (fixed)

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