Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
views_csv_source
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
views_csv_source
Merge requests
!3
Issue
#3446009
by andileco: Make column selector a select list based on the headers
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3446009
by andileco: Make column selector a select list based on the headers
issue/views_csv_source-3446009:3446009-make-column-selector
into
1.0.x
Overview
0
Commits
4
Pipelines
5
Changes
3
Merged
Daniel Cothran
requested to merge
issue/views_csv_source-3446009:3446009-make-column-selector
into
1.0.x
11 months ago
Overview
0
Commits
4
Pipelines
5
Changes
3
Expand
Closes
#3446009
0
0
Merge request reports
Compare
1.0.x
version 4
75c5dd6b
11 months ago
version 3
15e961ae
11 months ago
version 2
280ffde3
11 months ago
version 1
1e1a7675
11 months ago
1.0.x (base)
and
latest version
latest version
75c5dd6b
4 commits,
11 months ago
version 4
75c5dd6b
4 commits,
11 months ago
version 3
15e961ae
3 commits,
11 months ago
version 2
280ffde3
2 commits,
11 months ago
version 1
1e1a7675
1 commit,
11 months ago
3 files
+
61
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/Plugin/views/field/ViewsCsvField.php
+
17
−
1
Options
@@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface;
use
Drupal\Core\Render\Markup
;
use
Drupal\views\Plugin\views\field\FieldPluginBase
;
use
Drupal\views\ResultRow
;
use
Drupal\views_csv_source
\Plugin\views\query\ViewsCsvQuery
;
/**
* Base field handler for views_csv_source.
@@ -66,13 +67,28 @@ class ViewsCsvField extends FieldPluginBase {
*/
public
function
buildOptionsForm
(
&
$form
,
FormStateInterface
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
$form
[
'key'
]
=
[
'#title'
=>
$this
->
t
(
'Column Selector'
),
'#description'
=>
$this
->
t
(
'Choose a column'
),
'#type'
=>
'textfield'
,
'#default_value'
=>
$this
->
options
[
'key'
],
'#required'
=>
TRUE
,
];
// Get the query.
$query
=
$this
->
view
->
query
;
assert
(
$query
instanceof
ViewsCsvQuery
,
'Query must be of type ViewsCsvQuery'
);
// Ensure the query is of the correct type.
if
(
$headers
=
$query
->
getCsvHeader
())
{
$form
[
'key'
][
'#type'
]
=
'select'
;
$form
[
'key'
][
'#options'
]
=
array_combine
(
$headers
,
$headers
);
}
else
{
// Fall back to text value if CSV has not been selected.
$form
[
'key'
][
'#type'
]
=
'textfield'
;
}
$form
[
'trusted_html'
]
=
[
'#title'
=>
$this
->
t
(
'Trusted HTML'
),
'#description'
=>
$this
->
t
(
'This field is from a trusted source and contains raw HTML markup to render here. Use with caution.'
),
Loading