Right now ns_form is a feature that is named "Article Forms". This needs to be changed into a content provider called "Forms".
The feature should provide these entity reference fields
ns_article_ns_form
ns_page_ns_form
To support that these fields are optional (in defaultconfig) we need to implement something like
/**
* Implements hook_defaultconfig_optionals().
*/
function ns_form_defaultconfig_optionals() {
$optionals = array();
if (module_exists('ns_article')) {
$optionals['field_default_fields']['node-ns_article-field_ns_article_ns_form'] = array(
'title' => t('Article form'),
'description' => t('Attach form to articles.'),
'default' => FALSE,
);
$optionals['field_default_fields']['node-ns_page-field_ns_page_ns_form'] = array(
'title' => t('Page form'),
'description' => t('Attach form to pages.'),
'default' => FALSE,
);
}
return $optionals;
}
Comments
Comment #1
pontus_nilssonAlright, patch changes existing field to entityreference. Implements hook_defaultconfig_optionals(). and adds field for ns_page.
Comment #2
fabsor commentedA few issues here:
1. You changed the field definition hook to hook_field_default_fields. This means features will be taking care of the field import and not defaultconfig. The info file also reflects this. This will make it impossible to use the new defaultconfig API for optionals, and it would also make it impossible to make alterations on that field.
2. You changed the name of the field. In NodeStream we always prefix with the _feature_ name, not the actual content type. This is because fields with multiple instances are more common and in many cases preferred in Drupal 7. The original name was not really that good either since you could use the same field for more content types than ns_article in the future, but the new name is also incorrect =)
3. If we are going to change the name of a field, we are required to make an update hook reflecting those changes, otherwise we break a lot of sites.
Comment #3
gumdrop commentedSo can I ask what this content type supposed to be all about?
Comment #4
pontus_nilssonWith ns_form you can embed forms (webforms) on articles and pages. This way you can have a embedded form in an article or page.
Comment #5
gumdrop commentedOh I see, gotta create the title first and then the webform and it's components. Hmmm...trying to think of some useful scenario to use it in a newspaper.
Comment #6
fabsor commentedThis should be fixed now, as per #1404898: Turn all "extension" features into content providers.