[regression] Search forms with entities that include File custom fields don't render in Afform Admin screen
Steps to replicate.
- Create a searchkit search for any entity. Create a display. Save.
- Add the display to an afform in the Form Builder admin. Save.
- Create a new custom field of type "File" on the entity.
- Go back to Form Builder admin and try to edit the afform.
Expected Result
Works the same with or without the File custom field.
Actual result
Doesn't render, the error/backtrace below show up in the logs.
It's because there's no label_field
defined in the File schema XML - but it's not even clear to me what would be a good label field. We don't even store the filename by itself.
Error: Class name must be a valid object or a string in Civi\Api4\Utils\CoreUtil::getInfoItem() (line 63 of /var/www/example.org/vendor/civicrm/civicrm-core/Civi/Api4/Utils/CoreUtil.php)
#0 /var/www/example.org/vendor/civicrm/civicrm-core/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php(114): Civi\Api4\Utils\CoreUtil::getInfoItem('File', 'label_field')
#1 /var/www/example.org/vendor/civicrm/civicrm-core/ext/afform/admin/Civi/Api4/Action/Afform/LoadAdminData.php(205): Civi\AfformAdmin\AfformAdminMeta::getFields('Contribution', Array)
#2 /var/www/example.org/vendor/civicrm/civicrm-core/Civi/Api4/Provider/ActionObjectProvider.php(68): Civi\Api4\Action\Afform\LoadAdminData->_run(Object(Civi\Api4\Generic\Result))
#3 /var/www/example.org/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(149): Civi\Api4\Provider\ActionObjectProvider->invoke(Object(Civi\Api4\Action\Afform\LoadAdminData))
#4 /var/www/example.org/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php(232): Civi\API\Kernel->runRequest(Object(Civi\Api4\Action\Afform\LoadAdminData))
#5 /var/www/example.org/vendor/civicrm/civicrm-core/api/api.php(85): Civi\Api4\Generic\AbstractAction->execute()
#6 /var/www/example.org/vendor/civicrm/civicrm-core/CRM/Api4/Page/AJAX.php(139): civicrm_api4('Afform', 'loadAdminData', Array, NULL)
#7 /var/www/example.org/vendor/civicrm/civicrm-core/CRM/Api4/Page/AJAX.php(80): CRM_Api4_Page_AJAX->execute('Afform', 'loadAdminData', Array, '0')
#8 /var/www/example.org/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(313): CRM_Api4_Page_AJAX->run(Array, NULL)
#9 /var/www/example.org/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem(Array)
#10 /var/www/example.org/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke(Array)
#11 /var/www/example.org/web/modules/contrib/civicrm/src/Civicrm.php(88): CRM_Core_Invoke::invoke(Array)
#12 /var/www/example.org/web/modules/contrib/civicrm/src/Controller/CivicrmController.php(80): Drupal\civicrm\Civicrm->invoke(Array)
#13 [internal function]: Drupal\civicrm\Controller\CivicrmController->main(Array, 'Afform:loadAdmi...')
#14 /var/www/example.org/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#15 /var/www/example.org/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/example.org/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#17 /var/www/example.org/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#18 /var/www/example.org/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /var/www/example.org/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /var/www/example.org/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/example.org/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/example.org/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/example.org/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/example.org/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/example.org/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/example.org/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/example.org/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/example.org/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}