ContentEntityFormInterface
interface ContentEntityFormInterface implements EntityFormInterface (View source)
Defines a common interface for content entity form classes.
Methods
Determines which entity will be used by this form from a RouteMatch object.
Builds an updated entity object based upon the submitted form values.
Sets the string translation service for this form.
Sets the entity type manager for this form.
Sets the form display.
Checks whether the current form language matches the entity one.
Details
string
getFormId()
Returns a unique string identifying the form.
The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().
array
buildForm(array $form, FormStateInterface $form_state)
Form constructor.
validateForm(array $form, FormStateInterface $form_state)
Form validation handler.
submitForm(array $form, FormStateInterface $form_state)
Form submission handler.
string|null
getBaseFormId()
Returns a string identifying the base form.
$this
setOperation(string $operation)
Sets the operation for this form.
string
getOperation()
Gets the operation identifying the form.
EntityInterface
getEntity()
Gets the form entity.
The form entity which has been used for populating form element defaults.
$this
setEntity(EntityInterface $entity)
Sets the form entity.
Sets the form entity which will be used for populating form element defaults. Usually, the form entity gets updated by \Drupal\Core\Entity\EntityFormInterface::submit(), however this may be used to completely exchange the form entity, e.g. when preparing the rebuild of a multi-step form.
EntityInterface
getEntityFromRouteMatch(RouteMatchInterface $route_match, string $entity_type_id)
Determines which entity will be used by this form from a RouteMatch object.
EntityInterface
buildEntity(array $form, FormStateInterface $form_state)
Builds an updated entity object based upon the submitted form values.
For building the updated entity object the form's entity is cloned and the submitted form values are copied to entity properties. The form's entity remains unchanged.
int
save(array $form, FormStateInterface $form_state)
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
$this
setStringTranslation(TranslationInterface $string_translation)
Sets the string translation service for this form.
$this
setModuleHandler(ModuleHandlerInterface $module_handler)
Sets the module handler for this form.
$this
setEntityTypeManager(EntityTypeManagerInterface $entity_type_manager)
Sets the entity type manager for this form.
EntityFormDisplayInterface
getFormDisplay(FormStateInterface $form_state)
Gets the form display.
$this
setFormDisplay(EntityFormDisplayInterface $form_display, FormStateInterface $form_state)
Sets the form display.
Sets the form display which will be used for populating form element defaults.
string
getFormLangcode(FormStateInterface $form_state)
Gets the code identifying the active form language.
bool
isDefaultFormLangcode(FormStateInterface $form_state)
Checks whether the current form language matches the entity one.