Problem/Motivation
After installation, creating a new homebox type will lead to an error, if none of the submodules providing the portlets is enabled.
It makes no sense to create a homebox type without a portlet type available. Still it shouldn't lead to an error.
So we should either validate if at least one portlet value is given and otherwise show an error or we should set an empty array.
The website encountered an unexpected error. Try again later.
TypeError: Cannot assign string to property Drupal\homebox\Entity\HomeboxType::$homeboxTypePortletTypesSettings of type array in Drupal\Core\Config\Entity\ConfigEntityBase->set() (line 169 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drupal\Core\Entity\EntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 301)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 171)
Drupal\Core\Entity\EntityForm->afterBuild(Array, Object)
call_user_func_array(Array, Array) (Line: 1084)
Drupal\Core\Form\FormBuilder->doBuildForm('homebox_type_add_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('homebox_type_add_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Go to "/admin/structure/homebox_type/add"
- Add a label
- Press Save
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork homebox-3436787
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
anybodyOnly happens if no portlets are provided at all (submodules disabled). I updated the issue summary.
So it's a minor bug.
Comment #4
grevil commentedDone, please review!
Comment #5
anybodyWell done, this is fine and an edge-case!
Comment #6
anybodyComment #9
grevil commentedAll right, all done! Just a quick follow-up fix, I just configured the validation error from:
$form_state->setErrorByName('homeboxTypePortletTypesSettings'...to$form_state->setErrorByName('homebox_vertical_tabs', since the homeboxTypePortletTypesSettings form element might not exist at the point of the validation. This currently works either way, BUT might throw an exception in the future, so I quickly adjusted the code.