Call AJAX function in the beginning not just after change I've built a form that uses ajax to determine the number of text fields there should be based on a select field. It successfully adds the text fields based off the select field when it is changed, but it does not add the fields in the beginning before there is a change.

    $this-&gt;configuration['test'] = '3';
    $form['columnNum'] = [
        '#title'   =&gt; t('Number of Columns'),
        '#type'    =&gt; 'select',
        '#options' =&gt; [
            1         =&gt; '1',
            2         =&gt; '2',
            3         =&gt; '3',
            4         =&gt; '4',
        ],
        '#default_value' =&gt; $this-&gt;configuration['test'],
        '#empty_option'  =&gt; t('-select-'),
        '#ajax'          =&gt; [
            'callback'      =&gt; [$this, 'columnCallback'],
        ],
    ];

public function columnCallback(array&amp;$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $number   = $form_state-&gt;getValue(['settings', 'columnNum']);

    for ($i = 0; $i &lt; $number; $i += 1) {
        $columns[$i] = [
            '#type'  =&gt; 'textfield',
            '#title' =&gt; t('Column Title'),
            '#value' =&gt; $this-&gt;configuration['test'],
        ];
    }
    $content[] = [
        '#type'        =&gt; 'container',
        '#attributes'  =&gt; ['id'  =&gt; 'column_wrapper'],
        'columnTitles' =&gt; $columns,
    ];

    $response-&gt;addCommand(new ReplaceCommand('#column_wrapper', $content));
    return $response;
}


I've attempted lines this

$this-&gt;columnCallback();


But that failed.
Is there a way to get an ajax callback in the beginning before the field as well? Or is there a better way to do this entirely?
Rather than calling the AJAX function at the beginning I simply built the form as it should be in buildForm. Like so

    for ($i = 0; $i &lt; $this-&gt;configuration['test']; $i += 1) {
        $columns[$i] = [
            '#type'  =&gt; 'textfield',
            '#title' =&gt; t('Column Title'),
            '#value' =&gt; $this-&gt;configuration['test'],
        ];
    }
    $form['column_wrapper'] = [
        '#type'        =&gt; 'container',
        '#attributes'  =&gt; ['id'  =&gt; 'column_wrapper'],
        'columnTitles' =&gt; $columns,

    ];