Module overwrite user's custom help text

westbywest - April 23, 2009 - 15:27
Project:CCK Redirection
Version:5.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

cck_redirection.module does not honor any custom help text which the user enters for this field. The module is hardcoded to display "Enter a valid URI (i.e. http://www.example.com)."

To fix this, change these lines of cck_redirection.module:

function cck_redirection_widget($op, &$node, $field, &$items) {
  switch ($op) {
    case 'prepare form values':
      break;
    case 'form':
      $form = array();
      $form[$field['field_name']]['#tree'] = TRUE;
      $form[$field['field_name']][0]['value'] = array(
        '#type' => 'textfield',
        '#title' => t($field['widget']['label']),
        '#default_value' => $items[0]['value'],
        '#required' => $field['required'],
        '#description' => t('Enter a valid URI (!i).', array('!i' => 'i.e. http://www.example.com')),
      );

To this

function cck_redirection_widget($op, &$node, $field, &$items) {
  switch ($op) {
    case 'prepare form values':
      break;
    case 'form':
      $form = array();
      $form[$field['field_name']]['#tree'] = TRUE;
      $form[$field['field_name']][0]['value'] = array(
        '#type' => 'textfield',
        '#title' => t($field['widget']['label']),
        '#default_value' => $items[0]['value'],
        '#required' => $field['required'],
        '#description' => (isset($field['widget']['description']) && strlen($field['widget']['description']) ?
   $field['widget']['description'] :
   t('Enter a valid URI (!i).', array('!i' => 'i.e. http://www.example.com')) ),
      );

Unfortunately, I can't submit a patch, as the copy of my module has already been patched as per http://drupal.org/node/192897

 
 

Drupal is a registered trademark of Dries Buytaert.