Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
no-captcha
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CENTER-TBI
no-captcha
Commits
0f1d5bb7
Commit
0f1d5bb7
authored
Nov 22, 2018
by
Marivaldo Junior
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated displaySubmit to accept custom data-callback
parent
a5aefd96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
src/NoCaptcha.php
src/NoCaptcha.php
+11
-7
No files found.
src/NoCaptcha.php
View file @
0f1d5bb7
...
@@ -82,16 +82,20 @@ class NoCaptcha
...
@@ -82,16 +82,20 @@ class NoCaptcha
*/
*/
public
function
displaySubmit
(
$formIdentifier
,
$text
=
'submit'
,
$attributes
=
[])
public
function
displaySubmit
(
$formIdentifier
,
$text
=
'submit'
,
$attributes
=
[])
{
{
$javascript
=
''
;
if
(
!
isset
(
$attributes
[
'data-callback'
]))
{
$functionName
=
'onSubmit'
.
str_replace
([
'-'
,
'='
,
'\''
,
'"'
,
'<'
,
'>'
,
'`'
],
''
,
$formIdentifier
);
$functionName
=
'onSubmit'
.
str_replace
([
'-'
,
'='
,
'\''
,
'"'
,
'<'
,
'>'
,
'`'
],
''
,
$formIdentifier
);
$attributes
[
'data-callback'
]
=
$functionName
;
$attributes
[
'data-callback'
]
=
$functionName
;
$attributes
=
$this
->
prepareAttributes
(
$attributes
);
$button
=
sprintf
(
'<button%s><span>%s</span></button>'
,
$this
->
buildAttributes
(
$attributes
),
$text
);
$javascript
=
sprintf
(
$javascript
=
sprintf
(
'<script>function %s(){document.getElementById("%s").submit();}</script>'
,
'<script>function %s(){document.getElementById("%s").submit();}</script>'
,
$functionName
,
$functionName
,
$formIdentifier
$formIdentifier
);
);
}
$attributes
=
$this
->
prepareAttributes
(
$attributes
);
$button
=
sprintf
(
'<button%s><span>%s</span></button>'
,
$this
->
buildAttributes
(
$attributes
),
$text
);
return
$button
.
$javascript
;
return
$button
.
$javascript
;
}
}
...
...
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