Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
5a9c4bec
Commit
5a9c4bec
authored
Nov 06, 2013
by
catch
Browse files
Issue
#2126973
by damiankloip: FATAL error in Drupal\field\Plugin\views\field\Field::groupByForm.
parent
ea232c31
Changes
2
Show whitespace changes
Inline
Side-by-side
core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
View file @
5a9c4bec
...
...
@@ -7,9 +7,11 @@
namespace
Drupal\field\Plugin\views\field
;
use
Drupal\Component\Utility\MapArray
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Entity\EntityStorageControllerInterface
;
use
Drupal\field\Field
as
FieldHelper
;
use
Drupal\Core\Entity\FieldableDatabaseStorageController
;
use
Drupal\Core\Field\FieldDefinitionInterface
;
use
Drupal\Core\Field\FormatterPluginManager
;
...
...
@@ -137,12 +139,12 @@ public static function create(ContainerInterface $container, array $configuratio
public
function
init
(
ViewExecutable
$view
,
DisplayPluginBase
$display
,
array
&
$options
=
NULL
)
{
parent
::
init
(
$view
,
$display
,
$options
);
$this
->
field_info
=
$f
ield
=
field
_i
nfo
_f
ield
(
$this
->
definition
[
'entity_type'
],
$this
->
definition
[
'field_name'
]);
$this
->
field_info
=
F
ield
Helper
::
field
I
nfo
()
->
getF
ield
(
$this
->
definition
[
'entity_type'
],
$this
->
definition
[
'field_name'
]);
$this
->
multiple
=
FALSE
;
$this
->
limit_values
=
FALSE
;
$cardinality
=
$
field
->
getFieldCardinality
();
if
(
$
field
->
isFieldMultiple
())
{
$cardinality
=
$
this
->
field_info
->
getFieldCardinality
();
if
(
$
this
->
field_info
->
isFieldMultiple
())
{
$this
->
multiple
=
TRUE
;
// If "Display all values in the same row" is FALSE, then we always limit
...
...
@@ -606,9 +608,10 @@ public function buildGroupByForm(&$form, &$form_state) {
parent
::
buildGroupByForm
(
$form
,
$form_state
);
// With "field API" fields, the column target of the grouping function
// and any additional grouping columns must be specified.
$group_columns
=
array
(
'entity_id'
=>
t
(
'Entity ID'
),
)
+
drupal_map_assoc
(
array_keys
(
$this
->
field_info
[
'c
olumns
'
]
),
'ucfirst'
);
)
+
MapArray
::
copyValuesToKeys
(
array_keys
(
$this
->
field_info
->
getC
olumns
()
),
'ucfirst'
);
$form
[
'group_column'
]
=
array
(
'#type'
=>
'select'
,
...
...
@@ -618,7 +621,7 @@ public function buildGroupByForm(&$form, &$form_state) {
'#options'
=>
$group_columns
,
);
$options
=
drupal_map_assoc
(
array
(
'bundle'
,
'language'
,
'entity_type'
),
'ucfirst'
);
$options
=
MapArray
::
copyValuesToKeys
(
array
(
'bundle'
,
'language'
,
'entity_type'
),
'ucfirst'
);
// Add on defined fields, noting that they're prefixed with the field name.
$form
[
'group_columns'
]
=
array
(
...
...
core/modules/field/lib/Drupal/field/Tests/Views/FieldUITest.php
View file @
5a9c4bec
...
...
@@ -28,6 +28,16 @@ class FieldUITest extends FieldTestBase {
*/
public
static
$modules
=
array
(
'views_ui'
);
/**
* A user with the 'administer views' permission.
*
* @var \Drupal\user\UserInterface
*/
protected
$account
;
/**
* {@inheritdoc}
*/
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Field handler UI'
,
...
...
@@ -37,15 +47,22 @@ public static function getInfo() {
}
/**
*
Tests basic field handler settings in the UI.
*
{@inheritdoc}
*/
public
function
testHandlerUI
()
{
$account
=
$this
->
drupalCreateUser
(
array
(
'administer views'
));
$this
->
drupalLogin
(
$account
);
public
function
setUp
()
{
parent
::
setUp
();
$this
->
account
=
$this
->
drupalCreateUser
(
array
(
'administer views'
));
$this
->
drupalLogin
(
$this
->
account
);
$this
->
setUpFields
();
$this
->
setUpInstances
();
}
/**
* Tests basic field handler settings in the UI.
*/
public
function
testHandlerUI
()
{
$url
=
"admin/structure/views/nojs/config-item/test_view_fieldapi/default/field/field_name_0"
;
$this
->
drupalGet
(
$url
);
...
...
@@ -76,4 +93,27 @@ public function testHandlerUI() {
$this
->
assertEqual
(
$view
->
field
[
'field_name_0'
]
->
options
[
'settings'
][
'trim_length'
],
$random_number
);
}
/**
* Tests the basic field handler form when aggregation is enabled.
*/
public
function
testHandlerUIAggregation
()
{
// Enable aggregation.
$edit
=
array
(
'group_by'
=>
'1'
);
$this
->
drupalPostForm
(
'admin/structure/views/nojs/display/test_view_fieldapi/default/group_by'
,
$edit
,
t
(
'Apply'
));
$url
=
"admin/structure/views/nojs/config-item/test_view_fieldapi/default/field/field_name_0"
;
$this
->
drupalGet
(
$url
);
$this
->
assertResponse
(
200
);
// Test the click sort column options.
// Tests the available formatter options.
$result
=
$this
->
xpath
(
'//select[@id=:id]/option'
,
array
(
':id'
=>
'edit-options-click-sort-column'
));
$options
=
array_map
(
function
(
$item
)
{
return
(
string
)
$item
->
attributes
()
->
value
[
0
];
},
$result
);
sort
(
$options
,
SORT_STRING
);
$this
->
assertEqual
(
$options
,
array
(
'format'
,
'value'
),
'The expected sort field options were found.'
);
}
}
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