Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
fillpdf
Commits
096ea16a
Commit
096ea16a
authored
5 years ago
by
pancho
Committed by
Liam Morland
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #3023330 by Pancho, Liam Morland: Consolidate duplicate form field instances parsed by pdftk
parent
74585bfa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fillpdf.module
+18
-5
18 additions, 5 deletions
fillpdf.module
tests/FillPdfTestHelper.test
+2
-0
2 additions, 0 deletions
tests/FillPdfTestHelper.test
with
20 additions
and
5 deletions
fillpdf.module
+
18
−
5
View file @
096ea16a
...
...
@@ -1570,6 +1570,7 @@ function fillpdf_parse_pdf($fid) {
->
execute
();
// Create fields.
$unique_fields
=
array
();
foreach
((
array
)
$parsed_fields
as
$key
=>
$field
)
{
// Don't store "container" fields.
if
(
!
empty
(
$field
[
'type'
]))
{
...
...
@@ -1580,13 +1581,19 @@ function fillpdf_parse_pdf($fid) {
// improper parsing.
$field
[
'name'
]
=
str_replace
(
'�'
,
''
,
$field
[
'name'
]);
$record
=
array
(
'label'
=>
NULL
,
'value'
=>
''
,
);
fillpdf_fields_create_update
(
$fid
,
$field
[
'name'
],
$record
);
// Use the field name as key, so to consolidate duplicate fields.
$unique_fields
[
$field
[
'name'
]]
=
TRUE
;
}
}
// Save the fields that were parsed out (if any).
foreach
(
array_keys
(
$unique_fields
)
as
$pdf_key
)
{
$record
=
array
(
'label'
=>
NULL
,
'value'
=>
''
,
);
fillpdf_fields_create_update
(
$fid
,
$pdf_key
,
$record
);
}
}
/**
...
...
@@ -1774,6 +1781,12 @@ function fillpdf_execute_parse($method, $fillpdf, $mode = 'url') {
'value'
=>
''
,
'type'
=>
'Text'
,
),
// Test duplicate name.
3
=>
[
'name'
=>
'ImageField'
,
'value'
=>
''
,
'type'
=>
'Pushbutton'
,
],
);
break
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/FillPdfTestHelper.test
+
2
−
0
View file @
096ea16a
...
...
@@ -40,6 +40,8 @@ trait FillPdfTestHelper {
$this
->
drupalPost
(
'admin/structure/fillpdf'
,
array
(
'files[upload_pdf]'
=>
drupal_realpath
(
drupal_get_path
(
'module'
,
'fillpdf'
)
.
'/tests/fillpdf_test_v4.pdf'
),
),
t
(
'Upload'
));
$this
->
assertText
(
'fillpdf_test_v4.pdf was successfully uploaded.'
);
$this
->
assertResponse
(
200
,
"The duplicate field is consolidated and doesn't lead to an integrity constraint violation."
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Liam Morland
@lkmorlan
mentioned in commit
d4a3c053
·
5 years ago
mentioned in commit
d4a3c053
mentioned in commit d4a3c053396d0b5d794107a80ac639ade8c4084c
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment