protected function FormsStepsStepFormBase::copyFormValuesToEntity in Forms Steps 8
Copies top-level form values to entity properties.
This form can only change values for a step, which is part of forms_steps.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.
array $form: A nested array of form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides EntityForm::copyFormValuesToEntity
File
- src/
Form/ FormsStepsStepFormBase.php, line 438
Class
- FormsStepsStepFormBase
- Class FormsStepsStepFormBase.
Namespace
Drupal\forms_steps\FormCode
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
if ($form_state
->isSubmitted()) {
/** @var \Drupal\forms_steps\FormsStepsInterface $entity */
$values = $form_state
->getValues();
if (!$entity
->hasStep($values['id'])) {
$entity
->addStep($values['id'], $values['label'], $values['target_entity_type'], $values['target_entity_bundle'], $values['target_form_mode'], $values['url']);
}
if (!empty($values['label'])) {
$entity
->setStepLabel($values['id'], $values['label']);
}
if (!empty($values['target_entity_type'])) {
$entity
->setStepEntityType($values['id'], $values['target_entity_type']);
}
if (!empty($values['target_entity_bundle'])) {
$entity
->setStepEntityBundle($values['id'], $values['target_entity_bundle']);
}
if (!empty($values['target_form_mode'])) {
$entity
->setStepFormMode($values['id'], $values['target_form_mode']);
}
if (!empty($values['url'])) {
$entity
->setStepUrl($values['id'], $values['url']);
}
if ($values['override_submit'] == 1) {
$entity
->setStepSubmitLabel($values['id'], $values['submit_label']);
}
else {
$entity
->setStepSubmitLabel($values['id'], NULL);
}
if ($values['hide_delete'] == 1) {
$entity
->setStepDeleteState($values['id'], TRUE);
}
else {
$entity
->setStepDeleteState($values['id'], FALSE);
if ($values['override_delete'] == 1) {
$entity
->setStepDeleteLabel($values['id'], $values['delete_label']);
}
else {
$entity
->setStepDeleteLabel($values['id'], NULL);
}
}
if ($values['override_cancel'] == 1) {
$entity
->setStepCancelLabel($values['id'], $values['cancel_label']);
if ($values['set_cancel_route'] == 1) {
$entity
->setStepCancelStep($values['id'], NULL);
$entity
->setStepCancelStepMode($values['id'], NULL);
$entity
->setStepCancelRoute($values['id'], $values['cancel_route']);
}
else {
if ($values['set_cancel_step'] == 1) {
$entity
->setStepCancelRoute($values['id'], NULL);
$entity
->setStepCancelStep($values['id'], $entity
->getStep($values['cancel_step']));
}
}
}
else {
$entity
->setStepCancelLabel($values['id'], NULL);
}
if ($values['display_previous'] == 1) {
$entity
->setStepPreviousState($values['id'], TRUE);
$entity
->setStepPreviousLabel($values['id'], $values['previous_label']);
}
else {
$entity
->setStepPreviousState($values['id'], FALSE);
}
}
}