In my custom form, I am trying to create webform entities. Since webforms need unique machine names, I'm using the MachineName (machine_name) form element. The D8 MachineName element documentation suggests that we can get the field to auto-populate based on the text input of another field, AND there can be an AJAX callback to call a function that can check to see if the machine name is unique.
Neither is working for me. These are the form elements I am using.
//----------------- general settings ------------------ $form['settings'] = array( 'label' => ['#type' => 'textfield','#title' => 'Form Title'], 'id'=> array( '#type' => 'machine_name', 'label' => 'hh', '#source' => ['label'], '#maxlength' => 64, '#description' => $this->t('A unique name for this item. It must only contain lowercase letters, numbers, and underscores.'), '#machine_name' => array( 'exists' => array( $this, 'webform_id_exists', ), ), ), );
Can anyone advise? I have a callback function named, but no idea what it should look like.