Problem/Motivation
AutoTextfields::textfieldsCallback() contains the following code.
return $form['textfields_container'];
That is the wrong form element: AutoTextfields::buildForm() does not set $form['textfields_container'], but $form['text_fields_container'].
// Wrap text fields in a container. This container will be replaced through
// AJAX.
$form['text_fields_container'] = [
'#type' => 'container',
'#attributes' => ['id' => 'text-fields-container'],
];
$form['text_fields_container']['text_fields'] = [
'#type' => 'fieldset',
'#title' => $this->t("Generated text fields for first and last name"),
'#description' => $this->t('This is where we put automatically generated text fields'),
];
Proposed resolution
Replace AutoTextfields::textfieldsCallback() with the following code.
/**
* Callback for ajax_example_auto_text_fields.
*
* Selects the piece of the form we want to use as replacement markup and
* returns it as a form (renderable array).
*/
public function textfieldsCallback($form, FormStateInterface $form_state) {
return $form['text_fields_container'];
}
Comments
Comment #3
avpadernoComment #4
avpadernoComment #6
avpaderno