function _quickedit_render_field in Quick Edit 7
Renders a field.
If the view mode ID is not an Entity Display view mode ID, then the field was rendered using a custom render pipeline (not the Entity/Field API render pipeline).
An example could be Views' render pipeline. In that case, the view mode ID would probably contain the View's ID, display and the row index.
Parameters
$entity_type: The type of the entity being edited.
$entity: The entity being edited.
string $field_name: The name of the field that is being edited.
string $langcode: The name of the language for which the field is being edited.
string $view_mode: The view mode the field should be rerendered in. Either an Entity Display view mode ID, or a custom one. See hook_quickedit_render_field().
Return value
string Rendered HTML.
See also
1 call to _quickedit_render_field()
- quickedit_field_edit in includes/
pages.inc - Page callback: Returns a single field edit form as an Ajax response.
File
- includes/
pages.inc, line 138 - AJAX endpoint to retrieve & save subforms for fields and re-render fields.
Code
function _quickedit_render_field($entity_type, $entity, $field_name, $langcode, $view_mode) {
$entity_info = entity_get_info($entity_type);
$entity_view_mode_ids = array_keys($entity_info['view modes']);
if (in_array($view_mode, $entity_view_mode_ids)) {
if (!_quickedit_is_extra_field($entity_type, $field_name)) {
$field = field_view_field($entity_type, $entity, $field_name, $view_mode, $langcode);
$output = drupal_render($field);
}
else {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$rerender_callback = quickedit_extra_field_info($entity_type, $field_name, 'rerender callback');
$result = $rerender_callback($entity);
$output = quickedit_wrap_pseudofield($result['value'], "{$entity_type}/{$id}/{$field_name}/{$langcode}/{$view_mode}", $result['inline']);
}
}
else {
// Each part of a custom (non-Entity Display) view mode ID is separated
// by a dash; the first part must be the module name.
$mode_parts = explode('-', $view_mode, 2);
$module = reset($mode_parts);
$rendered_field = module_invoke($module, 'quickedit_render_field', $entity_type, $entity, $field_name, $view_mode, $langcode);
$output = drupal_render($rendered_field);
}
return $output;
}