3

I'm trying to update my field's data tables structure manually via phpmyadmin as I cannot modify it via the fields settings page since i have data in them. The thing is, where do I update the "fields settings" to encompass these table structure changes?

  • 1
    In field_config. I would never recommend doing this - can you elaborate on why? – Chris Rockwell Jul 22 '13 at 18:31
  • i need to update a a Date field to encompass "recurring" dates. Since i have data in that field already, the UI does not let me change that field setting. – Patoshi パトシ Jul 22 '13 at 20:30
16

Base field data is in field_config, and instance data is in field_config_instance. Rather than modifying them manually, though, you can always use the API:

$field = field_info_field('field_name');
$field['key'] = $new_value;
field_update_field($field);

Or for an instance

$instance = field_info_instance('node', 'field_name', 'article');
$instance['key'] = $new_value;
field_update_instance($instance);

Using the API will clear the appropriate caches, and it's just a better idea than editing the data manually.

Either way, make sure to backup the database first in case something goes horribly wrong :)

  • Direct SQL alteration also means that hook_field_update_field() doesn't fire. That may or may not cause problems. – mpdonadio Jul 22 '13 at 18:35
  • 1
    Oh, and a module can forbid alteration even if you use the API, and having data is a potential case for denial. – mpdonadio Jul 22 '13 at 18:38
  • whats the difference from field_config and field_config_instance tables? – Patoshi パトシ Jul 22 '13 at 20:31
  • also if i used the API's how would i know what they KEY that corresponds to the field setting i want to change? Here's a snapshot of what I found for the field_config table: img818.imageshack.us/img818/8804/e1yu.png ... it seems that the field settings is stored in the DATA column which cannot modify since its binary data? – Patoshi パトシ Jul 22 '13 at 20:55
  • 2
    field_config has the base field data (field name, type, cardinality, etc) and field_config_instance has the per-bundle settings (e.g. the specific settings for a field attached to a certain content type). The data column contains a serialised php string, which is why it's not recommended to edit the data directly. Using the info functions you can get the field/instance data, use dpm() or similar to inspect it, change some values just like you would a normal array, then use the update function to persist the changes – Clive Jul 22 '13 at 21:06

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.