Repository navigation
Description
Requested by: Jonathan Martínez
Problem
formidable-forms/list-fields (MCP/Abilities API) returns the generic MCP error "An error occurred while executing the tool." for some forms while get-form, list-form-actions and list-entries work on the same form. Reported via Help Scout 3485505405/259478 (Formidable Lite/Pro 7.0, WordPress 7.1.3).
Root cause (from code, not yet reproduced on a live site)
FrmAbilitiesFieldsController::prepare_field_for_response() (classes/controllers/FrmAbilitiesFieldsController.php) returns options and default_value unmodified, but the list-fields output schema is stricter than what Formidable stores. WordPress validates ability output against that schema (WP_Ability::validate_output, ability_invalid_output), so one bad field fails the whole form.
optionsis declaredtype => array. Choice fields can store options as an associative array keyed by option text (orother_<n>keys). That encodes as an object and fails the array check. Customer form 123 has 8 select/radio fields like this, e.g.{"1":{"label":"","value":""},"Asheville Sun Soo Martial Arts":{"label":"...","value":"..."}, ...}(73 keys).default_valueis declaredtype => string. Array defaults are saved as JSON (FrmField::update) and decoded back to an array on read (FrmField.php,unserialize_or_decode( $results->default_value )). An Address field default (line1,line2,city,state, ...) fails the string check. Checkbox fields with several defaults likely do too.
Fixing only options will not fix form 123, because it also has an Address field with an object default.
Fix
Widen the output schema. Do NOT array_values() the options: the other_<n> keys are functional.
options:type => array( array, object ), withitems/additionalPropertiesofarray( string, object ). This is the same shapecreate-fieldalready accepts for input in this file.default_value:type => array( string, array, object ).- Apply the same change to the
create-fieldandupdate-fieldoutput schemas in this file if they declare the same properties (they returnprepare_field_for_response()too). - Add a PHPUnit test to
tests/phpunit/fields/test_FrmAbilitiesFieldsController.php: a choice field with string-keyed options and a field with an arraydefault_valuemust passlist-fieldsoutput validation. Confirm it fails on the current code first. - Check
formidable-api/controllers/FrmAPIAbilitiesFieldsController.php(separate add-on repo, same schema properties at lines ~73-77, 167-177, 257-265) and file a matching issue there if it has the same strict types.
Notes
- Non-sequential integer keys (0, 2, 3) probably pass the WordPress array check; only string keys fail. Not confirmed against WP core source.
- The
formidable-mcp-skilldocs (references/forms-and-fields.md) already note an earlier fix that added object-form{label, value}items. This is the follow-on: string keys inoptions, anddefault_value.
Activity
vivi-the-going-merry commentedon Oct 16, 2026
Fix is up in #3581. The matching
formidable-apifollow-up is Strategy11/formidable-api#251.