1

I'm trying to convert a long-text field into a text-field. The only thing I found so far is the "field_config" table in the database. But any change there is only leading to errors. Do I have to change it somewhere else?

1
  • 1
    text fields by default have limited size, meaning if the long text exceeds that, you will run into some problems. The best way is probably to add a text field to the content type with the settings you want, and then use a one-off function to copy the data (trimming as necessary to fit in the new text field) directly in the database.
    – Geoff
    Jul 31, 2014 at 16:05

3 Answers 3

0

Once a field is created from admin then it can not be edited later. Because field data is saved in Binary form and can not be edited.

e.g if we have field 'test' then it will have table 'field_data_field_test' and 'field_revision_field_test' in the database. Now change its datatype directly in the database.

  1. Export these tables as a sql file and delete the old field in the manage field section of content type using admin.

  2. Create the new field with the same name as it was before and choose the appropriate datatype

  3. Now delete the newly created table 'field_data_field_test' and 'field_revision_field_test' and import the file that were exported earlier.

Other way you can create a new field and copy the data from old tables to new table and change settings later.

Hope it will help you!

0

Thanks to Geoff. As my long-text never was bigger than the textfield size (255) I could use this solution with ease. I did it the following:

Created a new field "textfield"
Did a database action:

INSERT INTO newtable (newfields)
SELECT oldfields FROM oldtable

and then deleted the old field.

0

I posted a php script that converts from text field to long_text field. You could easily reverse it:

How to convert text into long text?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.