public function ClusterForm::buildEntityForm in Elasticsearch Connector 8.5
Same name and namespace in other branches
- 8.7 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::buildEntityForm()
- 8 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::buildEntityForm()
- 8.2 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::buildEntityForm()
- 8.6 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::buildEntityForm()
1 call to ClusterForm::buildEntityForm()
- ClusterForm::form in src/
Form/ ClusterForm.php - Gets the actual form array to be built.
File
- src/
Form/ ClusterForm.php, line 79
Class
- ClusterForm
- Provides a form for the Cluster entity.
Namespace
Drupal\elasticsearch_connector\FormCode
public function buildEntityForm(array &$form, FormStateInterface $form_state) {
$form['cluster'] = array(
'#type' => 'value',
'#value' => $this->entity,
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Administrative cluster name'),
'#default_value' => empty($this->entity->name) ? '' : $this->entity->name,
'#description' => t('Enter the administrative cluster name that will be your Elasticsearch cluster unique identifier.'),
'#required' => TRUE,
'#weight' => 1,
);
$form['cluster_id'] = array(
'#type' => 'machine_name',
'#title' => t('Cluster id'),
'#default_value' => !empty($this->entity->cluster_id) ? $this->entity->cluster_id : '',
'#maxlength' => 125,
'#description' => t('A unique machine-readable name for this Elasticsearch cluster.'),
'#machine_name' => array(
'exists' => [
'Drupal\\elasticsearch_connector\\Entity\\Cluster',
'load',
],
'source' => array(
'name',
),
),
'#required' => TRUE,
'#disabled' => !empty($this->entity->cluster_id),
'#weight' => 2,
);
$form['url'] = array(
'#type' => 'textfield',
'#title' => t('Server URL'),
'#default_value' => !empty($this->entity->url) ? $this->entity->url : '',
'#description' => t('URL and port of a server (node) in the cluster. ' . 'Please, always enter the port even if it is default one. ' . 'Nodes will be automatically discovered. ' . 'Examples: http://localhost:9200 or https://localhost:443.'),
'#required' => TRUE,
'#weight' => 3,
);
$form['status_info'] = $this
->clusterFormInfo();
$default = $this->clusterManager
->getDefaultCluster();
$form['default'] = array(
'#type' => 'checkbox',
'#title' => t('Make this cluster default connection'),
'#description' => t('If the cluster connection is not specified the API will use the default connection.'),
'#default_value' => empty($default) || !empty($this->entity->cluster_id) && $this->entity->cluster_id == $default ? '1' : '0',
'#weight' => 4,
);
$form['options'] = array(
'#tree' => TRUE,
'#weight' => 5,
);
$form['options']['multiple_nodes_connection'] = array(
'#type' => 'checkbox',
'#title' => t('Use multiple nodes connection'),
'#description' => t('Automatically discover all nodes and use them in the cluster connection. ' . 'Then the Elasticsearch client can distribute the query execution on random base between nodes.'),
'#default_value' => !empty($this->entity->options['multiple_nodes_connection']) ? 1 : 0,
'#weight' => 5.1,
);
$form['status'] = array(
'#type' => 'radios',
'#title' => t('Status'),
'#default_value' => isset($this->entity->status) ? $this->entity->status : Cluster::ELASTICSEARCH_CONNECTOR_STATUS_ACTIVE,
'#options' => array(
Cluster::ELASTICSEARCH_CONNECTOR_STATUS_ACTIVE => t('Active'),
Cluster::ELASTICSEARCH_CONNECTOR_STATUS_INACTIVE => t('Inactive'),
),
'#required' => TRUE,
'#weight' => 6,
);
$form['options']['use_authentication'] = array(
'#type' => 'checkbox',
'#title' => t('Use authentication'),
'#description' => t('Use HTTP authentication method to connect to Elasticsearch.'),
'#default_value' => !empty($this->entity->options['use_authentication']) ? 1 : 0,
'#suffix' => '<div id="hosting-iframe-container"> </div>',
'#weight' => 5.2,
);
$form['options']['authentication_type'] = array(
'#type' => 'radios',
'#title' => t('Authentication type'),
'#description' => t('Select the http authentication type.'),
'#options' => array(
'Basic' => t('Basic'),
'Digest' => t('Digest'),
'NTLM' => t('NTLM'),
),
'#default_value' => !empty($this->entity->options['authentication_type']) ? $this->entity->options['authentication_type'] : 'Basic',
'#states' => array(
'visible' => array(
':input[name="options[use_authentication]"]' => array(
'checked' => TRUE,
),
),
),
'#weight' => 5.3,
);
$form['options']['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#description' => t('The username for authentication.'),
'#default_value' => !empty($this->entity->options['username']) ? $this->entity->options['username'] : '',
'#states' => array(
'visible' => array(
':input[name="options[use_authentication]"]' => array(
'checked' => TRUE,
),
),
),
'#weight' => 5.4,
);
$form['options']['password'] = array(
'#type' => 'textfield',
'#title' => t('Password'),
'#description' => t('The password for authentication.'),
'#default_value' => !empty($this->entity->options['password']) ? $this->entity->options['password'] : '',
'#states' => array(
'visible' => array(
':input[name="options[use_authentication]"]' => array(
'checked' => TRUE,
),
),
),
'#weight' => 5.5,
);
$form['options']['timeout'] = array(
'#type' => 'number',
'#title' => t('Connection timeout'),
'#size' => 20,
'#required' => TRUE,
'#description' => t('After how many seconds the connection should timeout if there is no connection to Elasticsearch.'),
'#default_value' => !empty($this->entity->options['timeout']) ? $this->entity->options['timeout'] : Cluster::ELASTICSEARCH_CONNECTOR_DEFAULT_TIMEOUT,
'#weight' => 5.6,
);
}