public function SupportTicketForm::buildEntity in Support Ticketing System 8
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.
Parameters
array $form: A nested array form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Entity\EntityInterface An updated copy of the form's entity object.
Overrides ContentEntityForm::buildEntity
See also
\Drupal\Core\Entity\EntityFormInterface::getEntity()
File
- modules/
support_ticket/ src/ SupportTicketForm.php, line 351 - Contains \Drupal\support_ticket\SupportTicketForm.
Class
- SupportTicketForm
- Form controller for the support ticket edit forms.
Namespace
Drupal\support_ticketCode
public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\support_ticket\SupportTicketInterface $entity */
$entity = parent::buildEntity($form, $form_state);
if (!empty($form_state
->getValue('uid')[0]['target_id']) && ($account = User::load($form_state
->getValue('uid')[0]['target_id']))) {
$entity
->setOwnerId($account
->id());
}
else {
$entity
->setOwnerId(0);
}
return $entity;
}