updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -151,10 +151,9 @@ class LinkWidget extends WidgetBase {
|
||||
*/
|
||||
public static function validateTitleElement(&$element, FormStateInterface $form_state, $form) {
|
||||
if ($element['uri']['#value'] !== '' && $element['title']['#value'] === '') {
|
||||
$element['title']['#required'] = TRUE;
|
||||
// We expect the field name placeholder value to be wrapped in t() here,
|
||||
// so it won't be escaped again as it's already marked safe.
|
||||
$form_state->setError($element['title'], t('@name field is required.', ['@name' => $element['title']['#title']]));
|
||||
$form_state->setError($element['title'], t('@title field is required if there is @uri input.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,12 +217,29 @@ class LinkWidget extends WidgetBase {
|
||||
'#default_value' => isset($items[$delta]->title) ? $items[$delta]->title : NULL,
|
||||
'#maxlength' => 255,
|
||||
'#access' => $this->getFieldSetting('title') != DRUPAL_DISABLED,
|
||||
'#required' => $this->getFieldSetting('title') === DRUPAL_REQUIRED && $element['#required'],
|
||||
];
|
||||
// Post-process the title field to make it conditionally required if URL is
|
||||
// non-empty. Omit the validation on the field edit form, since the field
|
||||
// settings cannot be saved otherwise.
|
||||
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_REQUIRED) {
|
||||
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') === DRUPAL_REQUIRED) {
|
||||
$element['#element_validate'][] = [get_called_class(), 'validateTitleElement'];
|
||||
|
||||
if (!$element['title']['#required']) {
|
||||
// Make title required on the front-end when URI filled-in.
|
||||
$field_name = $this->fieldDefinition->getName();
|
||||
|
||||
$parents = $element['#field_parents'];
|
||||
$parents[] = $field_name;
|
||||
$selector = $root = array_shift($parents);
|
||||
if ($parents) {
|
||||
$selector = $root . '[' . implode('][', $parents) . ']';
|
||||
}
|
||||
|
||||
$element['title']['#states']['required'] = [
|
||||
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Exposing the attributes array in the widget is left for alternate and more
|
||||
@@ -241,6 +257,29 @@ class LinkWidget extends WidgetBase {
|
||||
// title of the 'uri' element.
|
||||
if ($this->getFieldSetting('title') == DRUPAL_DISABLED) {
|
||||
$element['uri']['#title'] = $element['#title'];
|
||||
// By default the field description is added to the title field. Since
|
||||
// the title field is disabled, we add the description, if given, to the
|
||||
// uri element instead.
|
||||
if (!empty($element['#description'])) {
|
||||
if (empty($element['uri']['#description'])) {
|
||||
$element['uri']['#description'] = $element['#description'];
|
||||
}
|
||||
else {
|
||||
// If we have the description of the type of field together with
|
||||
// the user provided description, we want to make a distinction
|
||||
// between "core help text" and "user entered help text". To make
|
||||
// this distinction more clear, we put them in an unordered list.
|
||||
$element['uri']['#description'] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [
|
||||
// Assume the user-specified description has the most relevance,
|
||||
// so place it first.
|
||||
$element['#description'],
|
||||
$element['uri']['#description'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Otherwise wrap everything in a details element.
|
||||
else {
|
||||
|
||||
@@ -13,7 +13,9 @@ use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
* core = {6},
|
||||
* type_map = {
|
||||
* "link_field" = "link"
|
||||
* }
|
||||
* },
|
||||
* source_module = "link",
|
||||
* destination_module = "link"
|
||||
* )
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x and will be removed in Drupal 9.0.x. Use
|
||||
|
||||
@@ -13,7 +13,9 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
* core = {7},
|
||||
* type_map = {
|
||||
* "link_field" = "link"
|
||||
* }
|
||||
* },
|
||||
* source_module = "link",
|
||||
* destination_module = "link"
|
||||
* )
|
||||
*
|
||||
* This plugin provides the exact same functionality as the Drupal 6 "link"
|
||||
|
||||
@@ -11,7 +11,9 @@ use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
* core = {6},
|
||||
* type_map = {
|
||||
* "link_field" = "link"
|
||||
* }
|
||||
* },
|
||||
* source_module = "link",
|
||||
* destination_module = "link"
|
||||
* )
|
||||
*/
|
||||
class LinkField extends FieldPluginBase {
|
||||
|
||||
@@ -11,7 +11,9 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
* core = {7},
|
||||
* type_map = {
|
||||
* "link_field" = "link"
|
||||
* }
|
||||
* },
|
||||
* source_module = "link",
|
||||
* destination_module = "link"
|
||||
* )
|
||||
*
|
||||
* This plugin provides the exact same functionality as the Drupal 6 "link"
|
||||
@@ -20,6 +22,15 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*/
|
||||
class LinkField extends D6LinkField {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'link_default' => 'link',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,8 @@ class LinkViewsTokensTest extends ViewTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
ViewTestData::createTestViews(get_class($this), ['link_test_views']);
|
||||
|
||||
// Create Basic page node type.
|
||||
|
||||
Reference in New Issue
Block a user