Exemplo n.º 1
0
 /**
  * @inheritdoc
  *
  * N.B. massageFormValues and $element['#element_validate'] do comparable things.
  */
 public function massageFormValues(array $values, array $form, FormStateInterface $form_state)
 {
     $values = parent::massageFormValues($values, $form, $form_state);
     // Convert the values to real languagecodes,
     // but ONLY on Entity form, NOT in the 'field settings - default value'.
     if (isset($form_state->getBuildInfo()['form_id']) && $form_state->getBuildInfo()['form_id'] !== 'field_config_edit_form') {
         foreach ($values as &$value) {
             $value['value'] = LanguageItem::_getLanguageConfigurationValues($value['value']);
         }
     }
     return $values;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function massageFormValues(array $values, array $form, FormStateInterface $form_state)
 {
     $values = parent::massageFormValues($values, $form, $form_state);
     // It is likely that the url provided for this field is not existing and
     // so the logic in the parent method did not set any defaults. Just run
     // through all url values and add defaults.
     foreach ($values as &$value) {
         if (!empty($value['path'])) {
             // In case we have query process the url.
             if (strpos($value['path'], '?') !== FALSE) {
                 $url = UrlHelper::parse($value['path']);
                 $value['path'] = $url['path'];
                 $value['query'] = $url['query'];
             }
         }
     }
     return $values;
 }