public function IndexForm::buildEntityForm in Elasticsearch Connector 8.7
Same name and namespace in other branches
- 8 src/Form/IndexForm.php \Drupal\elasticsearch_connector\Form\IndexForm::buildEntityForm()
- 8.2 src/Form/IndexForm.php \Drupal\elasticsearch_connector\Form\IndexForm::buildEntityForm()
- 8.5 src/Form/IndexForm.php \Drupal\elasticsearch_connector\Form\IndexForm::buildEntityForm()
- 8.6 src/Form/IndexForm.php \Drupal\elasticsearch_connector\Form\IndexForm::buildEntityForm()
Builds entity form.
Parameters
array $form: Form parameter.
\Drupal\Core\Form\FormStateInterface $form_state: Form state parameter.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to IndexForm::buildEntityForm()
- IndexForm::form in src/
Form/ IndexForm.php - Gets the actual form array to be built.
File
- src/
Form/ IndexForm.php, line 197
Class
- IndexForm
- Form controller for node type forms.
Namespace
Drupal\elasticsearch_connector\FormCode
public function buildEntityForm(array &$form, FormStateInterface $form_state) {
// TODO: Provide check and support for other index modules settings.
// TODO: Provide support for the rest of the dynamic settings.
// TODO: Make sure that on edit the static settings cannot be changed.
// @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html
$form['index'] = [
'#type' => 'value',
'#value' => $this->entity,
];
$form['name'] = [
'#type' => 'textfield',
'#title' => t('Index name'),
'#required' => TRUE,
'#default_value' => '',
'#description' => t('Enter the index name.'),
'#weight' => 1,
];
$form['index_id'] = [
'#type' => 'machine_name',
'#title' => t('Index id'),
'#default_value' => '',
'#maxlength' => 125,
'#description' => t('Unique, machine-readable identifier for this Index'),
'#machine_name' => [
'exists' => [
$this
->getIndexStorage(),
'load',
],
'source' => [
'name',
],
'replace_pattern' => '[^a-z0-9_]+',
'replace' => '_',
],
'#required' => TRUE,
'#disabled' => !empty($this->entity->index_id),
'#weight' => 2,
];
// Here server refers to the elasticsearch cluster.
$form['server'] = [
'#type' => 'radios',
'#title' => $this
->t('Server'),
'#default_value' => !empty($this->entity->server) ? $this->entity->server : $this->clusterManager
->getDefaultCluster(),
'#description' => $this
->t('Select the server this index should reside on. Index can not be enabled without connection to valid server.'),
'#options' => $this
->getClusterField('cluster_id'),
'#weight' => 9,
'#required' => TRUE,
];
$form['num_of_shards'] = [
'#type' => 'textfield',
'#title' => t('Number of shards'),
'#required' => TRUE,
'#default_value' => 5,
'#description' => t('Enter the number of shards for the index.'),
'#weight' => 3,
];
$form['num_of_replica'] = [
'#type' => 'textfield',
'#title' => t('Number of replica'),
'#default_value' => 1,
'#description' => t('Enter the number of shards replicas.'),
'#weight' => 4,
];
$form['codec'] = [
'#type' => 'select',
'#title' => t('Codec'),
'#default_value' => !empty($this->entity->codec) ? $this->entity->codec : 'default',
'#description' => t('Select compression for stored data. Defaults to: LZ4.'),
'#options' => [
'default' => 'LZ4',
'best_compression' => 'DEFLATE',
],
'#weight' => 5,
];
}