/**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     if (!$form_state->isValueEmpty('variants')) {
         foreach ($form_state->getValue('variants') as $variant_id => $data) {
             if ($variant_entity = $this->entity->getVariant($variant_id)) {
                 $variant_entity->setWeight($data['weight']);
                 $variant_entity->save();
             }
         }
     }
     parent::save($form, $form_state);
     drupal_set_message($this->t('The %label page has been updated.', ['%label' => $this->entity->label()]));
     $form_state->setRedirect('entity.page.collection');
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     parent::save($form, $form_state);
     drupal_set_message($this->t('The %label page has been added.', ['%label' => $this->entity->label()]));
     $form_state->setRedirect('entity.page.edit_form', ['page' => $this->entity->id()]);
 }