public function SolrFieldTypeForm::form in Apache Solr Multilingual 8
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/ SolrFieldTypeForm.php, line 22 - Contains Drupal\apachesolr_multilingual\Form\SolrFieldTypeForm.
Class
- SolrFieldTypeForm
- Class SolrFieldTypeForm.
Namespace
Drupal\apachesolr_multilingual\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$solr_field_type = $this->entity;
$form['label'] = array(
'#type' => 'SolrFieldType',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $solr_field_type
->label(),
'#description' => $this
->t("Label for the SolrFieldType."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $solr_field_type
->id(),
'#machine_name' => array(
'exists' => '\\Drupal\\apachesolr_multilingual\\Entity\\SolrFieldType::load',
),
'#disabled' => !$solr_field_type
->isNew(),
);
/* You will need additional form elements for your custom properties. */
$form['field_type'] = array(
'#type' => 'textarea',
'#title' => $this
->t('FieldType'),
'#description' => $this
->t('FieldType.'),
'#default_value' => $solr_field_type
->getFieldTypeAsJson(),
);
$form['text_files'] = array(
'#type' => 'fieldset',
'#title' => $this
->t('Text Files'),
'#tree' => TRUE,
);
$text_files = $solr_field_type
->getTextFiles();
foreach ($text_files as $text_file_name => $text_file) {
$form['text_files'][$text_file_name] = array(
'#type' => 'textarea',
'#title' => $text_file_name,
'#default_value' => $text_file,
);
}
return $form;
}