public function SubgroupFormStep2::save in Subgroup (Graph) 1.0.x
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.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides GroupContentForm::save
File
- src/
Form/ SubgroupFormStep2.php, line 46
Class
- SubgroupFormStep2
- Provides a form creating a subgroup.
Namespace
Drupal\ggroup\FormCode
public function save(array $form, FormStateInterface $form_state) {
$storage_id = $form_state
->get('storage_id');
$store = $this->privateTempStoreFactory
->get('ggroup_add_temp');
// We can now safely save the group and set its ID on the group content.
$group = $store
->get("{$storage_id}:group");
$group
->save();
$this->entity
->set('entity_id', $group
->id());
// We also clear the private store so we can start fresh next time around.
$store
->delete("{$storage_id}:step");
$store
->delete("{$storage_id}:group");
return parent::save($form, $form_state);
}