Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
304
Merge Requests
304
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
f5ec8253
Commit
f5ec8253
authored
May 10, 2013
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1985138
by Berdir, Gábor Hojtsy: Fixed New autocomplete taxonomy terms not previewable.
parent
0bdc4cc7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
18 deletions
+61
-18
core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+50
-3
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php
...eld/formatter/EntityReferenceTaxonomyTermRssFormatter.php
+2
-2
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php
.../Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php
+3
-4
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/PlainFormatter.php
...Drupal/taxonomy/Plugin/field/formatter/PlainFormatter.php
+1
-4
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php
.../taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php
+2
-2
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php
...taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php
+2
-2
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
...xonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
+1
-1
No files found.
core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
View file @
f5ec8253
...
...
@@ -68,7 +68,8 @@ function setUp() {
'parent'
=>
'0'
,
),
),
)
),
'cardinality'
=>
'-1'
,
);
field_create_field
(
$this
->
field
);
...
...
@@ -77,7 +78,7 @@ function setUp() {
'entity_type'
=>
'node'
,
'bundle'
=>
'page'
,
'widget'
=>
array
(
'type'
=>
'
options_select
'
,
'type'
=>
'
taxonomy_autocomplete
'
,
),
// Hide on full display but render on teaser.
'display'
=>
array
(
...
...
@@ -90,6 +91,9 @@ function setUp() {
),
);
field_create_instance
(
$this
->
instance
);
entity_get_display
(
'node'
,
'page'
,
'default'
)
->
setComponent
(
$this
->
field_name
)
->
save
();
}
/**
...
...
@@ -105,7 +109,7 @@ function testPagePreview() {
$edit
=
array
();
$edit
[
$title_key
]
=
$this
->
randomName
(
8
);
$edit
[
$body_key
]
=
$this
->
randomName
(
16
);
$edit
[
$term_key
]
=
$this
->
term
->
id
();
$edit
[
$term_key
]
=
$this
->
term
->
label
();
$this
->
drupalPost
(
'node/add/page'
,
$edit
,
t
(
'Preview'
));
// Check that the preview is displaying the title, body and term.
...
...
@@ -119,6 +123,49 @@ function testPagePreview() {
$this
->
assertFieldByName
(
$title_key
,
$edit
[
$title_key
],
'Title field displayed.'
);
$this
->
assertFieldByName
(
$body_key
,
$edit
[
$body_key
],
'Body field displayed.'
);
$this
->
assertFieldByName
(
$term_key
,
$edit
[
$term_key
],
'Term field displayed.'
);
// Save the node.
$this
->
drupalPost
(
'node/add/page'
,
$edit
,
t
(
'Save'
));
$node
=
$this
->
drupalGetNodeByTitle
(
$edit
[
$title_key
]);
// Check the term was displayed on the saved node.
$this
->
drupalGet
(
'node/'
.
$node
->
nid
);
$this
->
assertText
(
$edit
[
$term_key
],
'Term displayed.'
);
// Check the term appears again on the edit form.
$this
->
drupalGet
(
'node/'
.
$node
->
nid
.
'/edit'
);
$this
->
assertFieldByName
(
$term_key
,
$edit
[
$term_key
],
'Term field displayed.'
);
// Check with two new terms on the edit form, additionally to the existing
// one.
$edit
=
array
();
$newterm1
=
$this
->
randomName
(
8
);
$newterm2
=
$this
->
randomName
(
8
);
$edit
[
$term_key
]
=
$this
->
term
->
label
()
.
', '
.
$newterm1
.
', '
.
$newterm2
;
$this
->
drupalPost
(
'node/'
.
$node
->
nid
.
'/edit'
,
$edit
,
t
(
'Preview'
));
$this
->
assertRaw
(
'>'
.
$newterm1
.
'<'
,
'First new term displayed.'
);
$this
->
assertRaw
(
'>'
.
$newterm2
.
'<'
,
'Second new term displayed.'
);
// The first term should be displayed as link, the others not.
$this
->
assertLink
(
$this
->
term
->
label
());
$this
->
assertNoLink
(
$newterm1
);
$this
->
assertNoLink
(
$newterm2
);
$this
->
drupalPost
(
'node/add/page'
,
$edit
,
t
(
'Save'
));
// Check with one more new term, keeping old terms, removing the existing
// one.
$edit
=
array
();
$newterm3
=
$this
->
randomName
(
8
);
$edit
[
$term_key
]
=
$newterm1
.
', '
.
$newterm3
.
', '
.
$newterm2
;
$this
->
drupalPost
(
'node/'
.
$node
->
nid
.
'/edit'
,
$edit
,
t
(
'Preview'
));
$this
->
assertRaw
(
'>'
.
$newterm1
.
'<'
,
'First existing term displayed.'
);
$this
->
assertRaw
(
'>'
.
$newterm2
.
'<'
,
'Second existing term displayed.'
);
$this
->
assertRaw
(
'>'
.
$newterm3
.
'<'
,
'Third new term displayed.'
);
$this
->
assertNoText
(
$this
->
term
->
label
());
$this
->
assertNoLink
(
$newterm1
);
$this
->
assertNoLink
(
$newterm2
);
$this
->
assertNoLink
(
$newterm3
);
$this
->
drupalPost
(
'node/add/page'
,
$edit
,
t
(
'Save'
));
}
/**
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/EntityReferenceTaxonomyTermRssFormatter.php
View file @
f5ec8253
...
...
@@ -38,9 +38,9 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) {
foreach
(
$items
as
$delta
=>
$item
)
{
$entity
->
rss_elements
[]
=
array
(
'key'
=>
'category'
,
'value'
=>
$item
[
'
target_id'
]
!=
'autocreate'
?
$item
[
'entity'
]
->
label
()
:
$item
[
'label'
]
,
'value'
=>
$item
[
'
entity'
]
->
label
()
,
'attributes'
=>
array
(
'domain'
=>
$item
[
'target_id'
]
!=
'autocreate'
?
url
(
'taxonomy/term/'
.
$item
[
'target_id'
],
array
(
'absolute'
=>
TRUE
))
:
''
,
'domain'
=>
$item
[
'target_id'
]
?
url
(
'taxonomy/term/'
.
$item
[
'target_id'
],
array
(
'absolute'
=>
TRUE
))
:
''
,
),
);
}
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php
View file @
f5ec8253
...
...
@@ -33,12 +33,11 @@ class LinkFormatter extends TaxonomyFormatterBase {
public
function
viewElements
(
EntityInterface
$entity
,
$langcode
,
array
$items
)
{
$elements
=
array
();
// Terms whose tid is 'autocreate' do not exist yet and $item['entity'] is
// not set. Theme such terms as just their name.
// Terms without tid do not exist yet, theme such terms as just their name.
foreach
(
$items
as
$delta
=>
$item
)
{
if
(
$item
[
'tid'
]
==
'autocreate'
)
{
if
(
!
$item
[
'tid'
]
)
{
$elements
[
$delta
]
=
array
(
'#markup'
=>
check_plain
(
$item
[
'
name'
]
),
'#markup'
=>
check_plain
(
$item
[
'
entity'
]
->
label
()
),
);
}
else
{
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/PlainFormatter.php
View file @
f5ec8253
...
...
@@ -33,12 +33,9 @@ class PlainFormatter extends TaxonomyFormatterBase {
public
function
viewElements
(
EntityInterface
$entity
,
$langcode
,
array
$items
)
{
$elements
=
array
();
// Terms whose tid is 'autocreate' do not exist yet and $item['entity'] is
// not set. Theme such terms as just their name.
foreach
(
$items
as
$delta
=>
$item
)
{
$name
=
(
$item
[
'tid'
]
!=
'autocreate'
?
$item
[
'entity'
]
->
label
()
:
$item
[
'name'
]);
$elements
[
$delta
]
=
array
(
'#markup'
=>
check_plain
(
$
name
),
'#markup'
=>
check_plain
(
$
item
[
'entity'
]
->
label
()
),
);
}
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php
View file @
f5ec8253
...
...
@@ -34,7 +34,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) {
// Terms whose tid is 'autocreate' do not exist yet and $item['entity'] is
// not set. Theme such terms as just their name.
foreach
(
$items
as
$item
)
{
if
(
$item
[
'tid'
]
!=
'autocreate'
)
{
if
(
$item
[
'tid'
])
{
$value
=
$item
[
'entity'
]
->
label
();
$uri
=
$item
[
'entity'
]
->
uri
();
...
...
@@ -42,7 +42,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) {
$domain
=
url
(
$uri
[
'path'
],
$uri
[
'options'
]);
}
else
{
$value
=
$item
[
'
name'
]
;
$value
=
$item
[
'
entity'
]
->
label
()
;
$domain
=
''
;
}
$entity
->
rss_elements
[]
=
array
(
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php
View file @
f5ec8253
...
...
@@ -30,7 +30,7 @@ public function prepareView(array $entities, $langcode, array &$items) {
foreach
(
$entities
as
$id
=>
$entity
)
{
foreach
(
$items
[
$id
]
as
$delta
=>
$item
)
{
// Force the array key to prevent duplicates.
if
(
$item
[
'tid'
]
!=
'autocreate'
&&
$item
[
'tid'
]
!=
=
FALSE
)
{
if
(
$item
[
'tid'
]
!==
FALSE
)
{
$tids
[
$item
[
'tid'
]]
=
$item
[
'tid'
];
}
}
...
...
@@ -51,7 +51,7 @@ public function prepareView(array $entities, $langcode, array &$items) {
$items
[
$id
][
$delta
][
'entity'
]
=
$terms
[
$item
[
'tid'
]];
}
// Terms to be created are not in $terms, but are still legitimate.
elseif
(
$item
[
'tid'
]
==
'autocreate'
)
{
elseif
(
$item
[
'tid'
]
==
=
FALSE
&&
isset
(
$item
[
'entity'
])
)
{
// Leave the item in place.
}
// Otherwise, unset the instance value, since the term does not exist.
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php
View file @
f5ec8253
...
...
@@ -86,7 +86,7 @@ public function massageFormValues(array $values, array $form, array &$form_state
// Translate term names into actual terms.
foreach
(
$values
as
$value
)
{
// See if the term exists in the chosen vocabulary and return the tid;
// otherwise, create a new
'autocreate' term for insert/update
.
// otherwise, create a new
term
.
if
(
$possibilities
=
entity_load_multiple_by_properties
(
'taxonomy_term'
,
array
(
'name'
=>
trim
(
$value
),
'vid'
=>
array_keys
(
$vocabularies
))))
{
$term
=
array_pop
(
$possibilities
);
$item
=
array
(
'tid'
=>
$term
->
id
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment