public function SolrFieldTypeExportForm::form in Search API Solr 8.2
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ SolrFieldTypeExportForm.php, line 17
Class
- SolrFieldTypeExportForm
- Builds the form to export a SolrFieldType.
Namespace
Drupal\search_api_solr\FormCode
public function form(array $form, FormStateInterface $form_state) {
\Drupal::messenger()
->addWarning($this
->t('In the future, this form will be used to export and push specific parts of the current SolrFieldType configuration to a Solr server based on a manged schema. But at the moment you can only see in which parts the SolrFiledType is split and how they\'re serialized.'));
/** @var \Drupal\search_api_solr\Entity\SolrFieldType $solr_field_type */
$solr_field_type = $this->entity;
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $solr_field_type
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\search_api_solr\\Entity\\SolrFieldType::load',
],
'#disabled' => TRUE,
];
$form['field_type'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Field Type'),
];
$form['field_type']['json'] = [
'#type' => 'textarea',
'#title' => $this
->t('JSON'),
'#description' => $this
->t('JSON representation to be used for solr REST API and managed schemas.'),
'#default_value' => $solr_field_type
->getFieldTypeAsJson(),
'#disabled' => TRUE,
];
$form['field_type']['xml'] = [
'#type' => 'textarea',
'#title' => $this
->t('XML'),
'#description' => $this
->t('XML representation to be used as part of schema.xml.'),
'#default_value' => $solr_field_type
->getFieldTypeAsXml(),
'#disabled' => TRUE,
];
$form['solr_configs'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Solr configs'),
];
$form['solr_configs']['xml'] = [
'#type' => 'textarea',
'#title' => $this
->t('XML'),
'#description' => $this
->t('XML representation to be used as part of solrconfig.xml.'),
'#default_value' => $solr_field_type
->getSolrConfigsAsXml(),
'#disabled' => TRUE,
];
$form['text_files'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Text Files'),
];
$text_files = $solr_field_type
->getTextFiles();
foreach ($text_files as $text_file_name => $text_file) {
$form['text_files'][$text_file_name] = [
'#type' => 'textarea',
'#title' => Utility::completeTextFileName($text_file_name, $solr_field_type),
'#default_value' => $text_file,
'#disabled' => TRUE,
];
}
return $form;
}