コード例 #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;
 }
コード例 #2
0
ファイル: LanguageFormatter.php プロジェクト: dev981/gaptest
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     $settings = $this->getSettings()['format'];
     $options = LanguageItem::_settingsOptions('formatter');
     if (empty($settings)) {
         $summary[] = t('** Not set **');
     } else {
         foreach ($settings as $key => $value) {
             switch ($value) {
                 case '0':
                     // Option is not selected.
                     break;
                 default:
                     $summary[] = isset($options[$value]) ? $options[$value] : '...';
                     break;
             }
         }
     }
     return $summary;
 }