Form APi Could not parse property path Unexpected token

Using

  • Drupal 9.1.4
  • symfony/property-access I think is on 5.2.0 (that’s the last version mentioned in the changelog)

I have a custom built form with some date and number fields, for example:

$form('calculator')('chargeable_consideration') = (
  '#type' => 'number',
  '#min' => 0,
  '#step' => 0.01,
  '#required' => TRUE,
  '#size' => 13,
  '#attributes' => (
    'placeholder' => '£0.00',
  ),
  '#title' => $this->t('description text (£) <button class="tooltip-anchor" title="pop up text">?</button>'),
  '#prefix' => '<div class="form-group">',
  '#suffix' => '</div>',
);

I have validation checking the dates are within a range, but nothing to check the numbers.

if I use the numbers

  • 10000.85
  • 123456789.70
  • 1234567890

the form works as expected.

If I use the numbers

I get the following error

SymfonyComponentPropertyAccessExceptionInvalidPropertyPathException: Could not parse property path "calculator)(chargeable_consideration". Unexpected token "(" at position 11. in SymfonyComponentPropertyAccessPropertyPath->__construct() (line 111 of vendorsymfonyproperty-accessPropertyPath.php).
SymfonyComponentPropertyAccessPropertyAccessor->getPropertyPath('calculator)(chargeable_consideration') (Line: 120)
SymfonyComponentPropertyAccessPropertyAccessor->getValue(Array, 'calculator)(chargeable_consideration') (Line: 406)
Drupalcustom_formFormCustomForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)

How do I prevent it from throwing this exception?