Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
So, I don't really want the #description for my field to read "Format: 2008-8-11," but I can't figure out how to override it. Personally, I don't think this module should be automatically providing field descriptions at all, but maybe that's just me...
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThat's done because with a text field you need to give the user an idea of what they are expected to provide, since dates can be in so many possible formats.
But I agree it's reasonable to allow for a way to override that, so this is a feature request. Feature requests go against the -dev version, so I'm changing that.
Comment #2
tirdadc CreditAttribution: tirdadc commentedChiming in to say this feature would be nice to have. I initially figured I'd be able to modify it with a hook_form_alter(), but that didn't work given the setup with date_popup_elements().
Comment #3
ohthehugemanatee CreditAttribution: ohthehugemanatee commentedNoting that this applies to 7.x as well. There's an expectation that a form element's description can be overridden with hook_form_alter on $form['fieldname']['#description'], but this doesn't work for date fields.
You CAN modify the description if you override $form_state['field']['fieldname']['und']['instance']['description'], but this is not normal. I'm not sure if this is a feature request or a low priority bug - field descriptions are SUPPOSED to be overrideable from the $form variable.
Comment #4
capellicA bit surprised that this issue hasn't gotten more attention seeing as it breaks core functionality. If I enter a string for "Help text" on the field edit form, that text should appear as the description text on the node form. It should only be a question of whether or not the the "e.g." string should be appended to whatever the site builder adds or not, or if there is an option on the field edit form to allow the site builder to suppress it or allow it to append.
Here are some resources on how to overcome this bug:
http://drupal.stackexchange.com/questions/28228/how-to-remove-format-des...
http://www.webpixel.gr/blog/drupal/remove-format-description-in-date_pop...
Comment #5
capellicWhile this resource (http://drupal.stackexchange.com/questions/28228/how-to-remove-format-des...) shows us how to remove the helper text added by the popup widget, it's this resource (http://drupal.stackexchange.com/questions/28228/how-to-remove-format-des...) that gets us on our way to applying the description text we have defined for the helper text.
In a custom module, add these two functions where 'mymodule' is substituted for your module machine name and 'content_type_machinename' is substituted for whatever your field collection machine name is.
In my case, I needed a date field that was on a field collection which was attached to a content type. All you have to do is substitute the line with the call to field_info_instance() above with the one below where 'field_collection_machinename' is the machine name of your field collection.
Comment #6
fonant CreditAttribution: fonant at Fonant Ltd commentedCapellic's code didn't work for me, but this did: