I want to increase the node title length on Drupal 7, and as I guess I need to do just two things (theoretically).
- Change the title column in the node table to acept more than 255 characters.
- Alter the node creating/editing form to let the title field accept more than 255 characters.
I've done, #2 and trying to get #1 using this code:
/** * Implements hook_schema_alter(). */ function my_module_schema_alter(&$schema){ if(isset($schema['node'])){ dsm($schema['node']); $schema['node']['fields']['title'] = array( 'type' => 'varchar', 'length' => 555, 'not null' => TRUE, 'default' => '', ); dsm($schema['node']); } } If I check dsm() before and after, I can see a change, but I don't see the title column in the node table affected. Am I missing something or using the bad hook?
I also use this code to change the form on creating/editing nodes (this works well):
/** * Implements hook_form_alter(). */ function my_module_form_alter(&$form, &$form_state, $form_id){ if($form['#id'] == 'norma-node-form'){ $form['title']['#type'] = 'textarea'; $form['title']['#maxlength'] = 555; } }
$entity->field_new_title['und'][0]['value'] = $entity->title; node_save($entity);And then hide the title node generating a new one with auto_nodetitles module.