Drupal 7 Date - Is there a way to change field settings if there is data in it already?

Solutions

I got this working by doing the following without having to write any code. Keep in mind im only doing this for the DATE type fields:

example:

my old field: field_eventdate

my new field: field_placeholder

  1. create the same field type with a different name and the options you want.
  2. open up phpmyadmin
  3. goto the table: field_config
  4. search for the new field you created (field_placeholder)
  5. click on the data column blob and download that.
  6. search and edit field_eventdate and upload the file you downloaded which contains the new settings.
  7. do the same exact thing for the table: field_config_instance
  8. now we have to update the table structures of the field to encompass these changes. I first inspected the strucuture of the new field i created and see what the old table was missing. Once you have that down, create the missing columns in the old field that exists in the new field.
  9. Do #8 again but this time for the revisions table. In my case it would be: field_revision_eventdate
  10. delete the field_placeholder via the content type page as you wont need it anymore.

let me know if this worked for anyone else too.

A more secure way than touching the database...

  1. First create your new field with the repeating date, let's call it field_event_date
  2. Then copy everything from the first field (field_date) to your new one

Code:

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', {your_content_type})
  ->addMetaData('account', user_load(1));

$result = $query->execute();
foreach($result['node'] as $nid => $n) {
  $node = node_load($nid);
  $node->field_event_date = $node->field_date;  // Copy one field to another
  node_save($node);
}  

I went about it by first capturing the original Date field with Features. Then, I created a field like I would like to target (similar to what you'd done with the placeholder) and Features-exported it. I compared the exported code and updated the original field's Feature export code, SQL-dumped the data from the field_data_field_.. table, deleted the original field by Manage Fields screen, feature-reverted to the modified Features export code, and then SQL-imported from my export. voila!

Similar questions

Is there any way to export data to CSV file and then import updated data?
I have a website I started to build couple years ago. But the website itself grew up to something bigger, with more fields and details - and old data are missing these. E.g., recently added Long./Lat. fields but old content doesn’t have them. So I wonder if it’s possible (and what module) to export all data into csv file, update it (I think it's mu...
Unable to install Pathauto, pathauto.settings already exists in active configuration
After upgrade from 8.7.10 to 8.9.13, i updated the pathauto module from ftp and trying to install from drupal admin but it showing an error like "Unable to install Pathauto, pathauto.settings already exists in active configuration." Based on the post https://www.drupal.org/forum/support/post-installation/2016-01-29/already-exists-in-activ...
Reference start date and end date for date field
I'm trying show some text when it falls between a certain date, but I am having trouble referencing the start date and end date of the date field. My code is: But it is not working because I do not think I am getting the value of the date in $date1 & $date2. My drupal field (named field_time) is set up as a Date (UNIX timestamp). I used the Dev...
date field missing when use date popup with date & time
in my custom module, I have used the following code: but after submitting it only show time field value. also work fine when only use date('d-m-y').
basic difference between Date, Date(ISO format), Date(Unix timestamp) to create a field
I have created a field as field type Date(Unix timestamp). When i edit a content with some input value in the above created field it shows an error like below:- But after deleting above field again i create another field as field type Date and i process same, it work. So my question is why it happening so for 1st case? And what are basic difference...
How to get archived events based on end date for a content type with a start date and end date field?
Create a content type Event with fields for Start date and End date. Validate the creation of events where Start date cannot be in the past and End date cannot be less than start date. Create a View where the Start date & End date are exposed filters and end date validated as in content creation page. The View should also filter expired events ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.