本文整理匯總了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;
}