FieldCollectionForm.php in Field collection 8.3
File
src/FieldCollectionForm.php
View source
<?php
namespace Drupal\field_collection;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class FieldCollectionForm extends EntityForm {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$field_collection = $this->entity;
if ($this->operation == 'add') {
$form['#title'] = $this
->t('Add field collection');
drupal_set_message(t('To add a field collection create a field of type field collection on the host entity type.'));
}
else {
$form['#title'] = $this
->t('Edit %label field collection', [
'%label' => $field_collection
->label(),
]);
$form['help'] = [
'#type' => 'markup',
'#markup' => t('<p>There are no options to edit for field collection bundles.</p><p><a href="@url">Manage fields inside this collection.</a></p>', [
'@url' => Url::fromRoute('entity.field_collection_item.field_ui_fields', [
$field_collection
->getEntityTypeId() => $field_collection
->id(),
]),
]),
];
}
return $form;
}
}