You are here

function hook_quickedit_render_field in Quick Edit 7

Returns a renderable array for the value of a single field in an entity.

To integrate with in-place field editing when a non-standard render pipeline is used (field_view_field() is not sufficient to render back the field following in-place editing in the exact way it was displayed originally), implement this hook.

Quick Edit module integrates with HTML elements with data-quickedit-field-id attributes. For example: data-quickedit-field-id="node/1/<field-name>/und/<module-name>-<custom-id>" After the editing is complete, this hook is invoked on the module with the custom render pipeline identifier (last part of data-quickedit-field-id) to re-render the field. Use the same logic used when rendering the field for the original display.

The implementation should take care of invoking the prepare_view steps. It should also respect field access permissions.

Parameters

string $entity_type: The type of the entity containing the field to display.

stdClass $entity: The entity containing the field to display.

string $field_name: The name of the field to display.

string $view_mode_id: View mode ID for the custom render pipeline this field view was destined for. This is not a regular view mode ID for the Entity/Field API render pipeline and is provided by the renderer module instead. An example could be Views' render pipeline. In the example of Views, the view mode ID would probably contain the View's ID, display and the row index. Views would know the internal structure of this ID. The only structure imposed on this ID is that it contains dash separated values and the first value is the module name. Only that module's hook implementation will be invoked. Eg. 'views-...-...'.

string $langcode: (Optional) The language code the field values are to be shown in.

Return value

A renderable array for the field value.

See also

field_view_field()

2 functions implement hook_quickedit_render_field()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

panelizer_quickedit_render_field in includes/panelizer.inc
Implements hook_quickedit_render_field().
quickedit_test_quickedit_render_field in tests/quickedit_test.module
Implements hook_quickedit_render_field().
1 invocation of hook_quickedit_render_field()
_quickedit_render_field in includes/pages.inc
Renders a field.

File

./quickedit.api.php, line 152
Hooks provided by the Quick Edit module.

Code

function hook_quickedit_render_field($entity_type, $entity, $field_name, $view_mode_id, $langcode) {
  return array(
    '#prefix' => '<div class="example-markup">',
    'field' => field_view_field($entity_type, $entity, $field_name, $view_mode_id, $langcode),
    '#suffix' => '</div>',
  );
}