Commit a6077acd authored by Kevin Einarsson's avatar Kevin Einarsson Committed by Ra Mänd
Browse files

Issue #2097583 by pjcdawkins, cyborg_572, kevineinarsson, Birk, michfuer:...

Issue #2097583 by pjcdawkins, cyborg_572, kevineinarsson, Birk, michfuer: Formatting property on table fields
parent cb1c3cbe
Loading
Loading
Loading
Loading
+3 −0
Changes for includes/entity.inline_entity_form.inc: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ class EntityInlineEntityFormController {
   *   - formatter: The formatter used to display the field, or "hidden".
   *   - settings: An array passed to the formatter. If empty, defaults are used.
   *   - delta: If provided, limits the field to just the specified delta.
   *   Special keys for type 'property', both optional:
   *   - formatter callback: A formatter callback used to display a property.
   *   - formatter arguments: Extra arguments to pass to the formatter callback.
   */
  public function tableFields($bundles) {
    $info = entity_get_info($this->entityType);
+8 −10
Changes for inline_entity_form.api.php: 8 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -68,16 +68,14 @@ function hook_inline_entity_form_settings_alter(&$settings, $field, $instance) {
 *   - type: either 'property', 'field' or 'callback' to specify how the data is
 *     defined on the related entity.
 *   - label: the title of the table field's column in the IEF table.
 *   - sanitized: for 'property' type table fields, a boolean indicating whether
 *     or not the data has already been sanitized for output; if not present or
 *     FALSE, theme_inline_entity_form_entity_table() will sanitize the data for
 *     output using check_plain().
 *   - formatter: for 'field' type table fields, the machine-name of the display
 *     formatter to use to render the field data. If this is used, then further
 *     keys will be set in the array passed to field_view_field() as the
 *     $display parameter. This allows any of the settings defined in the field
 *     formatter's hook_field_formatter_info() to be used.
 *   - weight: the sort order of the column in the IEF table.
 *   - weight: The position of the field relative to other fields.
 *   Special keys for type 'field', all optional:
 *   - formatter: The formatter used to display the field, or "hidden".
 *   - settings: An array passed to the formatter. If empty, defaults are used.
 *   - delta: If provided, limits the field to just the specified delta.
 *   Special keys for type 'property', all optional:
 *   - formatter callback: A formatter callback used to display a property.
 *   - formatter arguments: Extra arguments to pass to the formatter callback.
 *   - render_callback: for 'callback' type table fields, a function name that
 *     returns a renderable array.
 * @param $context
+20 −3
Changes for inline_entity_form.module: 20 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1756,9 +1756,26 @@ function theme_inline_entity_form_entity_table($variables) {
      $data = '';
      if ($field['type'] == 'property') {
        $property = $wrapper->{$field_name};
        // label() returns human-readable versions of token and list properties.
        $data = $property->label() ? $property->label() : $property->value();
        $data = empty($field['sanitized']) ? check_plain($data) : $data;
        // Handle formatter callbacks for properties.
        if (isset($field['formatter callback']) && is_callable($field['formatter callback'])) {
          $arguments = array($property->value());
          // If the 'formatter arguments' key is defined, the property value
          // will be the first argument to the formatter, while the other
          // arguments will be appended.
          if (isset($field['formatter arguments']) && is_array($field['formatter arguments'])) {
            $arguments = array_merge($arguments, $field['formatter arguments']);
          }
          $data = call_user_func_array($field['formatter callback'], $arguments);
        }
        else {
          // There's no formatter callback. The $property->label() method
          // returns human-readable versions for properties that have an
          // 'options list'.
          $data = $property->label();
          if (!$data) {
            $data = $property->value(array('sanitize' => TRUE));
          }
        }
      }
      elseif ($field['type'] == 'field' && isset($entity->{$field_name})) {
        $display = array(