buildForm breaks editing multiple choice custom field options
This is replicable on the https://agbu.jmaconsulting.biz site with the demo data:
- Go to Administer menu » Customize Data and Screens » Custom Fields.
- Select View and Edit Custom Fields next to Constituent Information.
- Select Edit Multiple Choice Options next to Most Important Issue or Marital Status.
- Observe bug 1: The multiple choice options are not displayed.
- Click Add Option for 'Most Important Issue'.
- Observe bug 2 - fatal error faulting the
buildForm
hook in thegrantprograms
extension.
Attached is the backtrace for bug 2. I imagine bug 1 is also a buildForm issue.
backTrace
#0 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Error.php(190): CRM_Core_Error::backtrace()
#1 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/PEAR.php(921): CRM_Core_Error::handle(Object(HTML_QuickForm_Error))
#2 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm.php(2084): PEAR_Error->__construct("element already exists", -6, 16, (Array:2), "Element 'description' already exists in HTML_QuickForm::addElement()")
#3 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/PEAR.php(575): HTML_QuickForm_Error->__construct(-6, 16, (Array:2), "Element 'description' already exists in HTML_QuickForm::addElement()")
#4 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/PEAR.php(236): PEAR::_raiseError(NULL, NULL, -6, 16, (Array:2), "Element 'description' already exists in HTML_QuickForm::addElement()", "HTML_QuickForm_Error", TRUE)
#5 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm.php(650): PEAR::__callStatic("raiseError", (Array:7))
#6 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Form.php(426): HTML_QuickForm->addElement("text", "description", "Mark", (Array:1), NULL)
#7 /home/git-civi-extensions/biz.jmaconsulting.grantprograms/grantprograms.php(517): CRM_Core_Form->add("text", "description", "Mark", (Array:1))
#8 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Utils/Hook.php(274): grantprograms_civicrm_buildForm("CRM_Custom_Form_Option", Object(CRM_Custom_Form_Option))
#9 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php(84): CRM_Utils_Hook->runHooks((Array:36), "civicrm_buildForm", 2, "CRM_Custom_Form_Option", Object(CRM_Custom_Form_Option), NULL, NULL, NULL, NULL)
#10 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php(90): CRM_Utils_Hook_DrupalBase->invokeViaUF(2, "CRM_Custom_Form_Option", Object(CRM_Custom_Form_Option), NULL, NULL, NULL, NULL, "civicrm_buildForm")
#11 [internal function](): Civi\Core\CiviEventDispatcher::delegateToUF(Object(Civi\Core\Event\GenericHookEvent), "hook_civicrm_buildForm", Object(Civi\Core\CiviEventDispatcher))
#12 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164): call_user_func((Array:2), Object(Civi\Core\Event\GenericHookEvent), "hook_civicrm_buildForm", Object(Civi\Core\CiviEventDispatcher))
#13 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(53): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch((Array:1), "hook_civicrm_buildForm", Object(Civi\Core\Event\GenericHookEvent))
#14 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php(167): Symfony\Component\EventDispatcher\EventDispatcher->dispatch("hook_civicrm_buildForm", Object(Civi\Core\Event\GenericHookEvent))
#15 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php(47): Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch("hook_civicrm_buildForm", Object(Civi\Core\Event\GenericHookEvent))
#16 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Utils/Hook.php(164): Civi\Core\CiviEventDispatcher->dispatch("hook_civicrm_buildForm", Object(Civi\Core\Event\GenericHookEvent))
#17 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Utils/Hook.php(425): CRM_Utils_Hook->invoke((Array:2), "CRM_Custom_Form_Option", Object(CRM_Custom_Form_Option), NULL, NULL, NULL, NULL, "civicrm_buildForm")
#18 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Form.php(618): CRM_Utils_Hook::buildForm("CRM_Custom_Form_Option", Object(CRM_Custom_Form_Option))
#19 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Display.php(92): CRM_Core_Form->buildForm()
#20 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Custom_Form_Option), "display")
#21 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Custom_Form_Option), "display")
#22 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("display")
#23 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Custom/Page/Option.php(210): CRM_Core_Controller->run()
#24 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Custom/Page/Option.php(278): CRM_Custom_Page_Option->edit(1)
#25 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php(309): CRM_Custom_Page_Option->run((Array:6), NULL)
#26 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#27 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:6))
#28 /home/agbu.jmaconsulting.biz/htdocs/sites/all/modules/civicrm/drupal/civicrm.module(445): CRM_Core_Invoke::invoke((Array:6))
#29 /home/agbu.jmaconsulting.biz/htdocs/includes/menu.inc(527): civicrm_invoke("admin", "custom", "group", "field", "option")
#30 /home/agbu.jmaconsulting.biz/htdocs/index.php(21): menu_execute_active_handler()
#31 {main}
Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
QuickForm Error: element already exists
Error Details
Additional Details:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -6
[message] => QuickForm Error: element already exists
[mode] => 16
[debug_info] => Element 'description' already exists in HTML_QuickForm::addElement()
[type] => HTML_QuickForm_Error
[user_info] => Element 'description' already exists in HTML_QuickForm::addElement()
[to_string] => [html_quickform_error: message="element already exists" code=-6 mode=callback callback=CRM_Core_Error::handle prefix="QuickForm Error: " info="Element 'description' already exists in HTML_QuickForm::addElement()"]
)