2

I've created the field "Attending" that is attached to the user profile.
I have created a form with one checkbox element; when submitted, I've confirmed that the attending_fielddatabase is being updated with the current value (0 or 1), but when I view the user profile through the UI, the updated value isn't being displayed.

The submit handler I am using is the following:

function rsvp_aform_submit($form, &$form_state) {
  global $user;
  db_query("UPDATE {field_data_field_attending} SET field_attending_value = :val WHERE entity_id = :eid", array(':val' => $form_state['values']['rsvp'], ':eid' => $user->uid));
  drupal_set_message(t('Your form has been saved.'));
}

Do you have any idea?

1 Answer 1

2

I think that's the caching. First try to clear the cache manually. If that helps you should use cache_clear_all() to clear the corresponding cache tables (e.g. cache_content, cache_views_data) after you update the db.

6
  • Hah! I thought I was done getting blindsided by caching... thanks so much. I'll upvote when I have the reputation May 10, 2011 at 14:25
  • In fact, what worked for me was drupal_flush_all_caches(). May 10, 2011 at 14:47
  • ok, but it's a little overkill to clear all caches and rebuild the theme_registry every time this form is submitted. thats simply not necessary and could result in performance shortage.
    – nonsenz
    May 10, 2011 at 14:53
  • Hmm.. I'll need to dig into it then - cache_clear_all() didn't do the trick.. May 10, 2011 at 15:05
  • have you passed the $table parameter? check which cache table you need to clear. maybe just take a look inside your db to find the guilty ones and try. take a look at api for more info on how to use cache_clear_all().
    – nonsenz
    May 10, 2011 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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