- 🇨🇳China jungle Chongqing, China
Thanks for opening this, 4.0.x is the dev branch for ^9.4 || ^10
Adding a managed_file field after step1 of the Wizard multi-step AJAX form example breaks the form. For the sake completeness and usefulness, this example should support all types of fields, including Managed Files.
1. Enable the ajax_example module
2. Edit examples/modules/ajax_example/src/Form/Wizard.php by adding a new managed_file field on step2:
...
case 2:
$limit_validation_errors = [['step'], ['step1']];
$form['step1'] = [
'#type' => 'value',
'#value' => $form_state->getValue('step1'),
];
$form['step2'] = [
'#type' => 'fieldset',
'#title' => $this->t('Step 2: Street address info'),
];
$form['step2']['address'] = [
'#type' => 'textfield',
'#title' => $this->t('Your street address'),
'#default_value' => $form_state->hasValue(['step2', 'address']) ? $form_state->getValue(['step2', 'address']) : '',
'#required' => TRUE,
];
$form['step2']['test_file'] = [
'#type' => 'managed_file',
'#upload_location' => 'public://attachments/',
'#multiple' => TRUE,
'#description' => 'This is a description',
'#upload_validators' => [
'file_validate_extensions' => [],
'file_validate_size' => array(25600000)
],
'#default_value' => $form_state->hasValue(["step2", 'test_file']) ? $form_state->getValue(["step2", 'test_file']) : [],
];
break;
...
3. Navigate to your.site/examples/ajax-example/wizard
4. On the second step of the form, try to upload a File.
5. The form breaks (the ManagedFile field is gone)
Needs work
4.0
AJAX Example
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Thanks for opening this, 4.0.x is the dev branch for ^9.4 || ^10