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.
comment_field_extra_fields()
contains the following code.
foreach (node_type_get_types() as $type) {
if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
$return['comment']['comment_node_' . $type->type] = array(
'form' => array(
'author' => array(
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
),
'subject' => array(
'label' => t('Subject'),
'description' => t('Subject textfield'),
'weight' => -1,
),
),
);
}
}
The problem is that if you make a custom module with too light weight, comment.module erase all extra fields.
The code should be the following.
foreach (node_type_get_types() as $type) {
if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
$return['comment']['comment_node_' . $type->type]['form'] ['author']= array(
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
);
$return['comment']['comment_node_' . $type->type]['form'] ['subject']= array(
'label' => t('Subject'),
'description' => t('Subject textfield'),
'weight' => -1,
);
}
Comment | File | Size | Author |
---|---|---|---|
#2 | 1953202.patch | 1020 bytes | jalpesh |
Comments
Comment #1
vpshah86 CreditAttribution: vpshah86 at Clarion Technologies commentedComment #2
jalpesh CreditAttribution: jalpesh as a volunteer and at Cybage Software Pvt Ltd. commentedHere are the patch for same..
Comment #3
jalpesh CreditAttribution: jalpesh as a volunteer and at Cybage Software Pvt Ltd. commentedComment #4
jalpesh CreditAttribution: jalpesh as a volunteer and at Cybage Software Pvt Ltd. commentedComment #5
apadernoComment #6
apadernoDoes it really reset all the extra fields?
hook_field_extra_fields()
implementations are invoked inFieldInfo::getBundleExtraFields()
, which uses the following code.Since
module_invoke_all()
merges the array it gets from the single implementations of that hook, it should not happen what described here.