Hello! First, thank you for a terrific module!

The question I have is how to change the allowed length of a poll choices field? I am using HTML and sometimes my poll choices are longer than the allowed field length. It would be great if site admin could change it without needing to hack the module. Btw, if hacking is the only solution here, maybe someone knows where in a module I can find the lines specifying the length of options field?

Comments

ChrisKennedy’s picture

Status: Active » Needs review
StatusFileSize
new1.29 KB

I think 2048 characters should do the trick.

ChrisKennedy’s picture

StatusFileSize
new1.36 KB

Here is a slight tweak to use variable_get() so that site admins can easily customize the max length by defining the Drupal variable advpoll_max_length (no need to create a UI for this though).

anders.fajerson’s picture

Status: Needs review » Reviewed & tested by the community

Looks nice. Maybe a more descriptive name though, e.g. advpoll_choice_max_length.

ChrisKennedy’s picture

Status: Reviewed & tested by the community » Fixed

Good point; I changed it to advpoll_choice_max_length.

http://drupal.org/cvs?commit=90690

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

el_pirata’s picture

Version: 5.x-1.x-dev » 7.x-3.x-dev

This is exactly what I'm after only I'm wondering if there's a fix for the most recent dev version.

I'm currently using AdvPoll version 7.x-3.x-dev and want to increase the length of the poll choice field.
Any suggestions on how to best accomplish this? ...and yes, I have data in that field from other polls....

off’s picture

Subscribe

justindodge’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

For 7.x-3.x: In advoll_field/advpoll_field.module under function advpoll_field_field_widget_form() is the FAPI definition for the choice textfield, but it's missing a '#maxlength' property and 128 appears to be the default.

The database definition for the field column is varchar (500), so it should be safe to go at least up to that number here. 128 is a little restrictive.

My code looks like this:

$element['choice'] = array(
        '#title' => check_plain($element['#title']),
        '#type' => 'textfield',
        '#size' => 110,
        '#maxlength' => 500, // Add a maxlength here.
        '#default_value' => empty($items[$delta]['choice']) ? '' : $items[$delta]['choice'],
        '#description' => check_plain($element['#description']),
        '#required' => $element['#required']
      );

Sorry I'm not making a patch, just tooling around with this and making a quick hack for fun purposes and thought I'd share.
Not sure if it's appropriate to re-open the issue, but I'm opening it so it can get some attention for 7.x

tripper54’s picture

Thanks for re-opening, this was not on my radar at all. Patches welcome!

natew’s picture

StatusFileSize
new644 bytes

Attached is a patch for Drupal 7 to increase the edit widget to allow up to 500 characters. I did some quick testing and this didn't seem to have any issues, and allowed us to enter up to 500 characters as a poll choice. Which is the amount allowed in the database.

natew’s picture

Status: Active » Needs review

The last submitted patch, 1: advpoll_max_length.patch, failed testing. View results

The last submitted patch, 2: advpoll_max_length.patch, failed testing. View results

nags338228’s picture

A code without hacking the module

/*
 * Field widget alter to allow more letters in Advance poll options
 */
function MYMOUDLE_field_widget_form_alter(&$element, &$form_state, &$context) {
  if ($context['field']['type'] == 'advpoll') {
    $element['choice']['#maxlength'] = 500;
  }
}
mikhailkrainiuk’s picture

Assigned: Unassigned » mikhailkrainiuk

mikhailkrainiuk’s picture

Assigned: mikhailkrainiuk » Unassigned
Status: Needs review » Fixed

Ok. Patch committed.

Status: Fixed » Closed (fixed)

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