本文整理汇总了PHP中Drupal\Core\Field\WidgetBase::massageFormValues方法的典型用法代码示例。如果您正苦于以下问题:PHP WidgetBase::massageFormValues方法的具体用法?PHP WidgetBase::massageFormValues怎么用?PHP WidgetBase::massageFormValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Field\WidgetBase
的用法示例。
在下文中一共展示了WidgetBase::massageFormValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: massageFormValues
/**
* @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: massageFormValues
/**
* {@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;
}