I have a few videos in my site that have really long titles and I noticed that there is a 35 character limit. Is there any specific reason for this limitation? It is pretty trivial to change the textfield to accept unlimited characters.

For anybody that needs this now heres the code.

<?php
 // file: emfield/contrib/emvideo/emvideo.module

function emvideo_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) {
  $element = array();
  if ($module == 'emvideo') {
    // Add a title field, but only if the field is allowed.
    // If the title is already being used allow it for editing even if it is disabled.
    if ($field['widget']['meta_fields']['title'] || !empty($items[$delta]['title'])) {
      $element['title'] = array(
        '#type' => 'textfield',
        '#title' => t('Video Title'),
        '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : '',
        '#size' => 60,
        '#maxlength' => 0, // Value changed to 0 from 35
        '#description' => t('The title for the video.'),
      );
    }
//    ...... more code
}
?>
CommentFileSizeAuthor
#4 emfield-title-length-991816-04.patch571 bytescluke009
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cluke009’s picture

Looks like we are limited by the actual database table in this instance and 255 is the most you can do.

<?php
 // file: emfield/contrib/emvideo/emvideo.module

function emvideo_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) {
  $element = array();
  if ($module == 'emvideo') {
    // Add a title field, but only if the field is allowed.
    // If the title is already being used allow it for editing even if it is disabled.
    if ($field['widget']['meta_fields']['title'] || !empty($items[$delta]['title'])) {
      $element['title'] = array(
        '#type' => 'textfield',
        '#title' => t('Video Title'),
        '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : '',
        '#size' => 60,
        '#maxlength' => 255, // Value changed to 0 from 255
        '#description' => t('The title for the video.'),
      );
    }
//    ...... more code
}
?>
agileadam’s picture

I've found a way to set the maxlength of the emvideo's title field through proper hooks, without touching the contrib module(s).

/**
 * Implementation of hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
        case 'vgallery_node_form':
            $form['#after_build'][] = '_vgallery_after_build';
            break;
    }
}

/**
 * Custom after_build callback handler for the video gallery node form
 */
function _vgallery_after_build($form, &$form_state) {
    _vgallery_set_title_maxlength($form['field_vgallery_videos']);
    return $form;
}

/**
 * Set the maxlength on the title field of a video gallery emvideo element
 */
function _vgallery_set_title_maxlength(&$elements) {
    foreach (element_children($elements) as $key) {
        if (isset($elements[$key]['emvideo']['title'])) {
            $elements[$key]['emvideo']['title']['#maxlength'] = 255;
        }
    }
}
jpamental’s picture

Just chiming in that I've had the same issue. I've only just started getting Git access set up but hope to contribute a patch that will set the title length at 255 (don't see any reason why it should be different than what the DB is set to allow).

Cheers,

Jason

cluke009’s picture

Version: 6.x-2.3 » 6.x-2.5
Status: Active » Needs review
FileSize
571 bytes

Decided to create a patch for this finally it is against the 6-2.x branch. Not sure if the patch naming convention is correct though.