Compatibility with Layout Builder

Created on 11 June 2020, about 4 years ago
Updated 14 February 2023, over 1 year ago

when I enabled layout builder for a content type that has bg_img_field, I got a fatal error "Unexpected error..." when attempting to edit in the layout builder.

On looking at Drupal Watchdog/database logs via drush ws the error seems to be:

  ID    Date           Type   Severity   Message                                                                                                                                        
 ----- -------------- ------ ---------- ----------------------------------------------------------------------------------------------------------------------------------------------- 
  278   11/Jun 20:35   php    Error      Error: Call to a member function getFileUri() on null in                                                                                       
                                         Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 321 of /var/www/html/web/modules            
  277   11/Jun 20:35   php    Notice     Notice: Undefined index: css_background_position in                                                                                            
                                         Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 279 of /var/www/html/web/modules/cont       
  276   11/Jun 20:35   php    Notice     Notice: Undefined index: css_background_size in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss()   
                                         (line 278 of /var/www/html/web/modules/contrib/                                                                                                
  275   11/Jun 20:35   php    Notice     Notice: Undefined index: css_repeat in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 277  
                                         of /var/www/html/web/modules/contrib/bg_img_fi                                                                                                 
  274   11/Jun 20:35   php    Notice     Notice: Undefined index: css_selector in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->buildElement() (line 218 of      
                                         /var/www/html/web/modules/contrib/bg_img_field/src                                                                                             
  273   11/Jun 20:26   cron   Notice     Cron run completed.                                                                                                                            
  272   11/Jun 20:26   cron   Notice     Execution of update_cron() took 10552.31ms.                                                                                                    
  271   11/Jun 20:26   cron   Warning    Attempting to re-run cron while it is already running.                                                                                         
  270   11/Jun 20:26   cron   Warning    Attempting to re-run cron while it is already running.                                                                                         
  269   11/Jun 20:26   cron   Warning    Attempting to re-run cron while it is already running.             

My thinking is that Drupal core and layout builder need to provide the option to exclude some fields from being controlled by them.

Thoughts?

πŸ› Bug report
Status

Closed: outdated

Version

1.6

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom therobyouknow

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mkindred

    @therobyouknow Is your install still working? I think I'm having the same issue in D9.5.2 using bg_img_field 8.x-1.7. I got the background image working without layout builder first, and then when I switched to layout builder, I can't get the image to display.

    Error message on the Manage Layout page for the paragraph:

    Notice: Undefined index: css_selector in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->buildElement() (line 218 of modules/contrib/bg_img_field/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php).
    Notice: Undefined index: css_repeat in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 277 of modules/contrib/bg_img_field/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php).
    Notice: Undefined index: css_background_size in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 278 of modules/contrib/bg_img_field/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php).
    Notice: Undefined index: css_background_position in Drupal\bg_img_field\Plugin\Field\FieldFormatter\BgImgFieldFormatter->generateBackgroundCss() (line 279 of modules/contrib/bg_img_field/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php).
    

    I'm hesitant to open a new issue, since your issue resolved itself.

Production build 0.69.0 2024