-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Labels
Description
Hi @signalpoint ,
I'm trying to create a module that supports the implementation of File module Drupal.
This is the code used, code that doesn't work.
function file_field_formatter_view(entity_type, entity, field, instance, langcode, items, display) {
try {
// Use this hook to render a field's content on an entity. Use dpm() to
// inspect the incoming arguments. The arguments contain field display
// settings from Drupal.
/*dpm(entity_type);
dpm(entity);
dpm(field);
dpm(instance);
dpm(langcode);
dpm(items);
dpm(display);*/
// Iterate over each item, and place a widget onto the render array.
var content = {};
$.each(items, function(delta, item) {
content[delta] = {
markup: 'empty($item['uri']) ? '' : file_create_url($item['uri'])'
};
});
return content;
}
catch (error) { console.log('file_field_formatter_view - ' + error); }
}
/**
* Implements hook_field_widget_form().
* @param {Object} form
* @param {Object} form_state
* @param {Object} field
* @param {Object} instance
* @param {String} langcode
* @param {Object} items
* @param {Number} delta
* @param {Object} element
*/
function file_field_widget_form(form, form_state, field, instance, langcode, items, delta, element) {
try {
// Use this hook to provide field widgets for form element items. This hook
// is called for each delta value on the field. Make modifications to the
// items collection using the provided delta value. The object contained
// within is a standard DrupalGap Forms API object, so you may assemble the
// field (and any children widgets) as needed.
// Very simple example, make the widget for the field a text field.
items[delta].type = 'file';
}
catch (error) { console.log('file_field_widget_form - ' + error); }
}
/**
* Called after a form element is assembled. Use it to alter a form element.
*/
//function hook_form_element_alter(form, element, variables) { }
/**
* Called after drupalgap_entity_render_field() assembles the field content
* string. Use this to make modifications to the HTML output of the entity's
* field before it is displayed. The field content will be inside of
* reference.content, so to make modifications, change reference.content. For
* more info: http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language
*/
function file_entity_post_render_field(entity, field_name, field, reference) {
if (field_name == 'field_documento') {
reference.content += '<h2>' + entity.title + '</h2>';
}
}
Any help please?
Thanks.