One of our sites began exhibiting a periodic bug where users would try to save their profiles and get an error about an illegal value in one of the fields (a cck field for "industry," fwiw, that we disabled by removing edit permissions for it a month ago). The field has a number of possible values as checkboxes, so users were able to pick more than one when the field was available to them for editing, prior to us disabling it.

We noted that admin users could save the profiles, and that they would then begin to be savable by users with normal privileges.

We zeroed in on the content_field_industry table, and began running through cases with assorted users before we finally figured out that field records with multiple deltas sometimes suffered from the issue, but other times didn't. After more digging around, we finally observed that:

  • if the record had more than one delta and values in the field_industry_value column had a leading space, the record would fail to save for normal users

  • if an admin user saved the user profile, any delta records with a leading space in the field_industry_value column would be destroyed and the profile would become editable by a normal user

  • if the record had more than one delta and the values in the field_industry_value column had no leading spaces, normal users could edit their profiles with no error

We don't want to lose the data, but we don't want it to be edited by normal users anymore, either, and we don't mind the thought of losing meaningless deltas (the ones that serve a historic purpose rather than a "this is a multiple selection" purpose).

Is there a safe way to clean up this issue, perhaps by simply deleting leading-space deltas?


Use a custom module and unset the field items using hook_form_alter(), or do it in your themes template.php.

* Implements hook_form_alter().
function YOUR_THEME_form_alter(&$form, &$form_state) {
  if ( $form_id= 'YOUR_FORM_ID' ) {
    // ... ADD MORE
  • an extra note to help you along ...You can use the dsm function to output the form id on all pages if you like. Simply add dsm($form); to your function in your theme folder or custom moduel before the if($form_id...) statement. – tecjam Nov 23 '11 at 9:07

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.