Created
March 25, 2015 18:36
-
-
Save theodorosploumis/6a08eb6e4e8c3ad5f3e8 to your computer and use it in GitHub Desktop.
Change drupal text field limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$field_to_update = 'field_text_field_to_extend'; //Replace with field slug | |
$new_chars = '500'; //Replace with extended character limit | |
$result1 = db_query('ALTER TABLE {field_data_'.$field_to_update.'} CHANGE '.$field_to_update.'_value '.$field_to_update.'_value VARCHAR('.$new_chars.')'); | |
$result2 = db_query('ALTER TABLE {field_revision_'.$field_to_update.'} CHANGE '.$field_to_update.'_value '.$field_to_update.'_value VARCHAR('.$new_chars.')'); | |
$result3 = db_query('SELECT CAST(data AS CHAR(10000) CHARACTER SET utf8) data FROM {field_config} WHERE field_name = \''.$field_to_update.'\''); | |
foreach ($result3 as $result) { | |
$data = $result->data; | |
} | |
$data_array = unserialize($data); | |
$data_array['settings']['max_length'] = $new_chars; | |
$new_data = serialize($data_array); | |
$result4 = db_query('UPDATE {field_config} SET data = :data WHERE field_name = :field', array(':data' => $new_data, ':field' => $field_to_update)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment