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

Replicator makes statamic crash when adding empty fieldset #1642

Closed
CodeAndWeb opened this Issue Nov 2, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@CodeAndWeb

CodeAndWeb commented Nov 2, 2017

Expected behaviour

I am using the replicator to build page blocks for a webpage. One of the blocks is a simple spacer with no fields.

fields:
  blocks:
    type: replicator
    sets:
      spacer:
        display: -----

Editing the set is no problem but you can't open any page using it.

ErrorException in PublishController.php line 310:
Undefined index: fields

I can add the fields manually:

      spacer:
        display: -----
        fields: []

As soon as you re-save the fieldset in the backend it always omits the empty array and it's broken again.

Actual behaviour

Crash when opening a page that is using fieldset in the backend.

Steps to reproduce

  1. create replicator
  2. add 1 empty set

Server Details

Operating System:

Mac 10.13

Web Server:

PHP internal

PHP Version:

7.1.8

Statamic Version:

2.7.1

Updated from an older Statamic or fresh install:

both

List of installed addons:

none

Logs

If any logs (browser, server, or Statamic) are appropriate...

``` in PublishController.php line 310 at HandleExceptions->handleError('8', 'Undefined index: fields', '/Users/sk/Programming/marvelmetrix-webpage/statamic/core/Http/Controllers/PublishController.php', '310', array('fields' => array('title' => array('type' => 'title', 'display' => 'Title', 'validate' => 'required', 'localizable' => true), 'description' => array('type' => 'textarea', 'display' => 'Description (SEO)', 'localizable' => true), 'visible_in_main_nav' => array('type' => 'toggle', 'display' => 'Visible in main nav', 'default' => false), 'blocks' => array('localizable' => true, 'type' => 'replicator', 'display' => 'Blocks', 'sets' => array('page-title' => array('display' => 'Page Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'text', 'display' => 'Content'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center', 'default' => 'true'))), 'section-title' => array('display' => 'Section Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'pre_title' => array('type' => 'text', 'display' => 'Pre-Title (optional)'), 'lead' => array('type' => 'text', 'display' => 'Lead'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')))), 'feature-text-3col' => array('display' => 'Features (3Col)', 'fields' => array('title1' => array('type' => 'text', 'display' => 'Title1'), 'content1' => array('type' => 'markdown', 'display' => 'Content2'), 'title2' => array('type' => 'text', 'display' => 'Title2'), 'content2' => array('type' => 'markdown', 'display' => 'Content2'), 'title3' => array('type' => 'text', 'display' => 'Title3'), 'content3' => array('type' => 'markdown', 'display' => 'Content3'))), 'feature-with-image' => array('display' => 'Features (Image)', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'textarea', 'display' => 'Content'), 'learn-more-link' => array('type' => 'pages', 'display' => 'Learn more link', 'max_items' => '1', 'mode' => 'tags'), 'learn-more-text' => array('type' => 'text', 'display' => 'Learn more text'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1'))), 'features-small-icon-above' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'description' => array('type' => 'textarea', 'display' => 'Description')), 'mode' => 'table'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')))), 'features-small-icon-links' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'link' => array('type' => 'pages', 'max_items' => '1')), 'mode' => 'table'))), 'markdown' => array('fields' => array('content' => array('type' => 'markdown', 'display' => 'content', 'cheatsheet' => true))), 'spacer' => array('display' => '-----'), 'cta' => array('fields' => array('title' => array('type' => 'text', 'display' => 'Title', 'instructions' => 'Use <span> to highlight parts of the CTA text'), 'sub_title' => array('type' => 'text', 'display' => 'Sub-Title'), 'cta' => array('type' => 'text', 'display' => 'CTA-Text'), 'cta_link' => array('type' => 'text', 'display' => 'CTA-Link'), 'style' => array('type' => 'select', 'display' => 'Style', 'options' => array('plain' => 'Default', 'border-white' => 'Border: White', 'border-primary' => 'Border: Primary', 'border-dark' => 'Border: Dark', 'fullwidth-white' => 'Full width: White', 'fullwidth-primary' => 'Full width: Primary', 'fullwidth-dark' => 'Full width: Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center'))), 'pricing' => array('fields' => array('tears' => array('type' => 'grid', 'display' => 'tears', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'value' => array('type' => 'text', 'display' => 'Value'), 'description' => array('type' => 'text', 'display' => 'Description'), 'payment' => array('type' => 'text', 'display' => 'Payment'), 'features' => array('type' => 'list', 'display' => 'Features'), 'featured' => array('type' => 'toggle', 'display' => 'Featured')), 'mode' => 'table'), 'cta' => array('type' => 'text', 'display' => 'CTA'))), 'team' => array('fields' => array('members' => array('type' => 'grid', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'name' => array('type' => 'text', 'display' => 'Name'), 'description' => array('type' => 'markdown', 'display' => 'Description'), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1')), 'mode' => 'stacked')))))), 'prefix' => '', 'suggestFields' => array('blockslearn-more-link' => array('type' => 'pages', 'display' => 'Learn more link', 'max_items' => '1', 'mode' => 'tags'), 'blocksfeatureslink' => array('type' => 'pages', 'max_items' => '1')), 'config' => array('localizable' => true, 'type' => 'replicator', 'display' => 'Blocks', 'sets' => array('page-title' => array('display' => 'Page Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'text', 'display' => 'Content'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center', 'default' => 'true'))), 'section-title' => array('display' => 'Section Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'pre_title' => array('type' => 'text', 'display' => 'Pre-Title (optional)'), 'lead' => array('type' => 'text', 'display' => 'Lead'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')))), 'feature-text-3col' => array('display' => 'Features (3Col)', 'fields' => array('title1' => array('type' => 'text', 'display' => 'Title1'), 'content1' => array('type' => 'markdown', 'display' => 'Content2'), 'title2' => array('type' => 'text', 'display' => 'Title2'), 'content2' => array('type' => 'markdown', 'display' => 'Content2'), 'title3' => array('type' => 'text', 'display' => 'Title3'), 'content3' => array('type' => 'markdown', 'display' => 'Content3'))), 'feature-with-image' => array('display' => 'Features (Image)', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'textarea', 'display' => 'Content'), 'learn-more-link' => array('type' => 'pages', 'display' => 'Learn more link', 'max_items' => '1', 'mode' => 'tags'), 'learn-more-text' => array('type' => 'text', 'display' => 'Learn more text'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1'))), 'features-small-icon-above' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'description' => array('type' => 'textarea', 'display' => 'Description')), 'mode' => 'table'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')))), 'features-small-icon-links' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'link' => array('type' => 'pages', 'max_items' => '1')), 'mode' => 'table'))), 'markdown' => array('fields' => array('content' => array('type' => 'markdown', 'display' => 'content', 'cheatsheet' => true))), 'spacer' => array('display' => '-----'), 'cta' => array('fields' => array('title' => array('type' => 'text', 'display' => 'Title', 'instructions' => 'Use <span> to highlight parts of the CTA text'), 'sub_title' => array('type' => 'text', 'display' => 'Sub-Title'), 'cta' => array('type' => 'text', 'display' => 'CTA-Text'), 'cta_link' => array('type' => 'text', 'display' => 'CTA-Link'), 'style' => array('type' => 'select', 'display' => 'Style', 'options' => array('plain' => 'Default', 'border-white' => 'Border: White', 'border-primary' => 'Border: Primary', 'border-dark' => 'Border: Dark', 'fullwidth-white' => 'Full width: White', 'fullwidth-primary' => 'Full width: Primary', 'fullwidth-dark' => 'Full width: Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center'))), 'pricing' => array('fields' => array('tears' => array('type' => 'grid', 'display' => 'tears', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'value' => array('type' => 'text', 'display' => 'Value'), 'description' => array('type' => 'text', 'display' => 'Description'), 'payment' => array('type' => 'text', 'display' => 'Payment'), 'features' => array('type' => 'list', 'display' => 'Features'), 'featured' => array('type' => 'toggle', 'display' => 'Featured')), 'mode' => 'table'), 'cta' => array('type' => 'text', 'display' => 'CTA'))), 'team' => array('fields' => array('members' => array('type' => 'grid', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'name' => array('type' => 'text', 'display' => 'Name'), 'description' => array('type' => 'markdown', 'display' => 'Description'), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1')), 'mode' => 'stacked'))))), 'handle' => 'blocks', 'type' => 'replicator', 'forceArrayKey' => 'taxonomy', 'set' => array('display' => '-----'))) in PublishController.php line 310 at PublishController->getSuggestFields(array('title' => array('type' => 'title', 'display' => 'Title', 'validate' => 'required', 'localizable' => true), 'description' => array('type' => 'textarea', 'display' => 'Description (SEO)', 'localizable' => true), 'visible_in_main_nav' => array('type' => 'toggle', 'display' => 'Visible in main nav', 'default' => false), 'blocks' => array('localizable' => true, 'type' => 'replicator', 'display' => 'Blocks', 'sets' => array('page-title' => array('display' => 'Page Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'text', 'display' => 'Content'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center', 'default' => 'true'))), 'section-title' => array('display' => 'Section Title', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'pre_title' => array('type' => 'text', 'display' => 'Pre-Title (optional)'), 'lead' => array('type' => 'text', 'display' => 'Lead'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array('white' => 'White', 'gray' => 'Gray', 'color' => 'Colored', 'dark' => 'Dark')))), 'feature-text-3col' => array('display' => 'Features (3Col)', 'fields' => array('title1' => array('type' => 'text', 'display' => 'Title1'), 'content1' => array('type' => 'markdown', 'display' => 'Content2'), 'title2' => array('type' => 'text', 'display' => 'Title2'), 'content2' => array('type' => 'markdown', 'display' => 'Content2'), 'title3' => array('type' => 'text', 'display' => 'Title3'), 'content3' => array('type' => 'markdown', 'display' => 'Content3'))), 'feature-with-image' => array('display' => 'Features (Image)', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'content' => array('type' => 'textarea', 'display' => 'Content'), 'learn-more-link' => array('type' => 'pages', 'display' => 'Learn more link', 'max_items' => '1', 'mode' => 'tags'), 'learn-more-text' => array('type' => 'text', 'display' => 'Learn more text'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1'))), 'features-small-icon-above' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'description' => array('type' => 'textarea', 'display' => 'Description')), 'mode' => 'table'), 'background' => array('type' => 'select', 'display' => 'Background', 'options' => array(': White', 'bg--primary' => 'Primary', 'bg--dark' => 'Dark', 'bg--secondary' => 'Secondary')))), 'features-small-icon-links' => array('fields' => array('features' => array('type' => 'grid', 'display' => 'features', 'fields' => array('title' => array('type' => 'title', 'display' => 'Title'), 'icon' => array('type' => 'text', 'display' => 'icon'), 'link' => array('type' => 'pages', 'max_items' => '1')), 'mode' => 'table'))), 'markdown' => array('fields' => array('content' => array('type' => 'markdown', 'display' => 'content', 'cheatsheet' => true))), 'spacer' => array('display' => '-----'), 'cta' => array('fields' => array('title' => array('type' => 'text', 'display' => 'Title', 'instructions' => 'Use <span> to highlight parts of the CTA text'), 'sub_title' => array('type' => 'text', 'display' => 'Sub-Title'), 'cta' => array('type' => 'text', 'display' => 'CTA-Text'), 'cta_link' => array('type' => 'text', 'display' => 'CTA-Link'), 'style' => array('type' => 'select', 'display' => 'Style', 'options' => array('plain' => 'Default', 'border-white' => 'Border: White', 'border-primary' => 'Border: Primary', 'border-dark' => 'Border: Dark', 'fullwidth-white' => 'Full width: White', 'fullwidth-primary' => 'Full width: Primary', 'fullwidth-dark' => 'Full width: Dark')), 'center' => array('type' => 'toggle', 'display' => 'Center'))), 'pricing' => array('fields' => array('tears' => array('type' => 'grid', 'display' => 'tears', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'value' => array('type' => 'text', 'display' => 'Value'), 'description' => array('type' => 'text', 'display' => 'Description'), 'payment' => array('type' => 'text', 'display' => 'Payment'), 'features' => array('type' => 'list', 'display' => 'Features'), 'featured' => array('type' => 'toggle', 'display' => 'Featured')), 'mode' => 'table'), 'cta' => array('type' => 'text', 'display' => 'CTA'))), 'team' => array('fields' => array('members' => array('type' => 'grid', 'fields' => array('title' => array('type' => 'text', 'display' => 'Title'), 'name' => array('type' => 'text', 'display' => 'Name'), 'description' => array('type' => 'markdown', 'display' => 'Description'), 'image' => array('type' => 'assets', 'display' => 'Image', 'container' => 'main', 'folder' => '/', 'max_files' => '1')), 'mode' => 'stacked'))))))) in PublishController.php line 271 at PublishController->getSuggestions(object(Fieldset)) in PublishPageController.php line 93 at PublishPageController->edit(object(Request), 'marvelmetrix/segmentierung') at call_user_func_array(array(object(PublishPageController), 'edit'), array(object(Request), 'url' => 'marvelmetrix/segmentierung')) in Controller.php line 256 at Controller->callAction('edit', array(object(Request), 'url' => 'marvelmetrix/segmentierung')) in ControllerDispatcher.php line 164 at ControllerDispatcher->call(object(PublishPageController), object(Route), 'edit') in ControllerDispatcher.php line 112 at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 at ControllerDispatcher->callWithinStack(object(PublishPageController), object(Route), object(Request), 'edit') in ControllerDispatcher.php line 68 at ControllerDispatcher->dispatch(object(Route), object(Request), 'Statamic\Http\Controllers\PublishPageController', 'edit') in Route.php line 203 at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 at Route->run(object(Request)) in Router.php line 708 at Router->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 62 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Outpost.php line 48 at Outpost->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Outpost), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Localize.php line 25 at Localize->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Localize), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in DefaultLocale.php line 28 at DefaultLocale->handle(object(Request), object(Closure)) at call_user_func_array(array(object(DefaultLocale), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CpEnabled.php line 23 at CpEnabled->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CpEnabled), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Router.php line 710 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 674 at Router->dispatchToRoute(object(Request)) in Router.php line 635 at Router->dispatch(object(Request)) in Kernel.php line 236 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Debugbar.php line 51 at Debugbar->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in PersistStache.php line 22 at PersistStache->handle(object(Request), object(Closure)) at call_user_func_array(array(object(PersistStache), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Retrieve.php line 33 at Retrieve->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Retrieve), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 122 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 at Kernel->handle(object(Request)) in index.php line 155 at require_once('/Users/sk/Programming/marvelmetrix-webpage/index.php') in server.php line 21 ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment