Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy value to the paragraphs field causing issue #196

Open
sudipto68 opened this issue Sep 12, 2024 · 1 comment
Open

Dummy value to the paragraphs field causing issue #196

sudipto68 opened this issue Sep 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sudipto68
Copy link

There is a function in the paragraph module's paragraphs.field_formatter.inc file like this:

/**
 * Implements hook_field_prepare_view().
 *
 * Adds a dummy value to the paragraphs field to make rendering possible.
 */
function paragraphs_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
  if ($field['type'] == 'paragraphs') {
    foreach ($items as $key => $item) {
      if (!isset($item[0]['value'])) {
        $items[$key][0]['value'] = 'scratch_paragraph';
      }
    }
  }
}

This function adds a dummy value scratch_paragraph in paragraph fields. For this dummy value, we faced an weird issue in our site.
We have a paragraph(i.e. Accordion) that is used as a field in page content type. If we create a page and don't create any paragraph, then also the paragraph is having a dummy value in its fields, for that the HTML structure is present in the node.tpl for the paragraph fields and it is showing the design we provided in the paragraph but don't have any value.

I don't know why this function with dummy value is used? Is there any use case for this?

@sudipto68 sudipto68 added the bug Something isn't working label Sep 12, 2024
@laryn
Copy link
Member

laryn commented Sep 12, 2024

@sudipto68 This 'scratch_paragraph' concept is not fully fleshed out, I'm afraid, but is/was intended to allow sites with front end modal editing enabled to insert a new paragraph from the front end, even if no paragraphs items are already present. In this case it would need to insert a blank "scratch paragraph" at the insertion point. At a minimum it should be checking that modal administration is activated and the current user has permissions for it, but I'm tempted to just remove this for now and when/if we bring this functionality in, we can do it all at once, cleanly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants