Hi All,
Problem/Motivation
The table field caption working well. Mostly the caption field is providing more information about the table as the description. So if caption field allows the end user to save HTML format means more helpful.

Proposed resolution
Making caption field as text_format instead of textefield

Remaining tasks
Need to handle display of caption render also.

User interface changes
Yes, Form field of saving caption.

API changes
Nil

Data model changes
Nil

Thanks in advance,
Arunkumar K

Comments

arunkumark created an issue. See original summary.

arunkumark’s picture

Issue summary: View changes
arunkumark’s picture

Status: Active » Needs review
StatusFileSize
new1.66 KB

I have created Patch for Caption Formatted Field.

lolandese’s picture

Status: Needs review » Needs work

Looks good for me. Maybe the existing table field defaults in the content type settings and table field values on existing content should be converted (preferably to Plain text format if it exists) in a hook_update_N().

arunkumark’s picture

Status: Needs work » Needs review
StatusFileSize
new2.25 KB

@lolandese thanks for guiding.

I have re-rolled patch for updating existing caption values that stored in the text field.

lolandese’s picture

Status: Needs review » Needs work

You should provide a new hook_update_N() as function tablefield_update_7007() instead of inserting code in the existing tablefield_update_7003().

arunkumark’s picture

Status: Needs work » Needs review
StatusFileSize
new4.3 KB

Created new patch that will clean version of the last patch with new hook_update_N

hgoto’s picture

Status: Needs review » Needs work

This is a nice improvement! I saw the patch #7 and found some points.

1.

+   // Change the default field for each content type.
+  $field_names = array();

We need to set a proper field names here, right? Or, you can use field_read_fields(['type' => 'tablefield']) and $field['storage']['details'] to get table names for Tablefield fields.

2.

+        // Rationalize the table data.
+        if (!empty($instance)) {
+          // Remove extraneous data.
+          $count_cols = $instance['rebuild']['count_cols'];
+          $count_rows = $instance['rebuild']['count_rows'];
+          $caption = $instance['caption'];
+          $rebuild = $instance['rebuild'];
+          $import = $instance['import'];
+          $paste = $instance['paste'];
+          unset($instance['caption']);
+          unset($instance['rebuild']);
+          unset($instance['import']);
+          unset($instance['paste']);
+        }
+
+        // Changing Caption format values for old data.
+        if (!is_array($caption)) {
+          $captionArray['value'] = $caption;
+          $captionArray['format'] = 'plain_text';
+          $caption = $captionArray;
+        }
+        // Recreate previous removed data.
+        $instance['caption'] = $caption;
+        $instance['rebuild'] = $rebuild;
+        $instance['import'] = $import;
+        $instance['paste'] = $paste;

What does part do? It seems we don't need to re-set rebuild, import and paste here. All we want to change is caption, right?

liam morland’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.