Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
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
Development
CiviCRM Core
Commits
2f8f4f9c
Commit
2f8f4f9c
authored
4 years ago
by
DaveD
Browse files
Options
Downloads
Patches
Plain Diff
avoid E_WARNING and remove code
parent
fe7338a3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Form.php
+0
-17
0 additions, 17 deletions
CRM/Core/Form.php
tests/phpunit/CRM/Core/FormTest.php
+7
-0
7 additions, 0 deletions
tests/phpunit/CRM/Core/FormTest.php
with
7 additions
and
17 deletions
CRM/Core/Form.php
+
0
−
17
View file @
2f8f4f9c
...
...
@@ -439,7 +439,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
unset
(
$extra
[
'option_context'
]);
}
$this
->
addRequiredAttribute
(
$required
,
$extra
);
$element
=
$this
->
addElement
(
$type
,
$name
,
CRM_Utils_String
::
purifyHTML
(
$label
),
$attributes
,
$extra
);
if
(
HTML_QuickForm
::
isError
(
$element
))
{
CRM_Core_Error
::
statusBounce
(
HTML_QuickForm
::
errorMessage
(
$element
));
...
...
@@ -1174,20 +1173,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
return
self
::
$_template
->
get_template_vars
(
$name
);
}
/**
* jQuery validate prefers to see a validation rule as a class (eg. "required").
* We can't add a class at the quickform level but jQuery validate also works with HTML5:
* HTML5 validation requires a separate attribute "required".
*
* @param $required
* @param $attributes
*/
private
function
addRequiredAttribute
(
$required
,
$attributes
)
{
// Ideally we do this by adding "required" as a class on the radio but we can't
// But adding the attribute "required" directly to the element also works.
$required
?
$attributes
[
'required'
]
=
1
:
NULL
;
}
/**
* @param string $name
* @param $title
...
...
@@ -1205,8 +1190,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
$allowClear
=
!
empty
(
$attributes
[
'allowClear'
]);
unset
(
$attributes
[
'allowClear'
]);
$attributes
[
'id_suffix'
]
=
$name
;
// For jquery validate we need to flag the actual radio as required.
$this
->
addRequiredAttribute
(
$required
,
$attributes
);
foreach
(
$values
as
$key
=>
$var
)
{
$optAttributes
=
$attributes
;
if
(
!
empty
(
$optionAttributes
[
$key
]))
{
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Core/FormTest.php
+
7
−
0
View file @
2f8f4f9c
...
...
@@ -65,6 +65,13 @@ class CRM_Core_FormTest extends CiviUnitTestCase {
$form
->
_action
=
CRM_Core_Action
::
BASIC
;
},
],
'New Price Field'
=>
[
'CRM_Price_Form_Field'
,
function
(
CRM_Core_Form
$form
)
{
$form
->
set
(
'sid'
,
1
);
$form
->
_action
=
CRM_Core_Action
::
ADD
;
},
],
];
}
...
...
This diff is collapsed.
Click to expand it.
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