Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
e0b1788b
Commit
e0b1788b
authored
Dec 06, 2019
by
Carsten Rose
Browse files
unify attributes for checkboxSingle
parent
58f8fd0f
Pipeline
#2882
passed with stages
in 3 minutes and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Core/Form/Checkbox.php
View file @
e0b1788b
...
...
@@ -17,7 +17,6 @@ namespace IMATHUZH\Qfq\Core\Form;
//use IMATHUZH\Qfq\Core\Helper\OnArray;
//use IMATHUZH\Qfq\Core\Helper\Sanitize;
use
IMATHUZH\Qfq\Core\Helper\Support
;
//use IMATHUZH\Qfq\Core\Report\Link;
//use IMATHUZH\Qfq\Core\Report\Report;
//use IMATHUZH\Qfq\Core\Store\Sip;
...
...
@@ -395,19 +394,30 @@ class Checkbox {
*/
public
function
buildCheckboxSingle
(
array
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
array
&
$json
,
$mode
=
FORM_LOAD
)
{
if
(
isset
(
$formElement
[
FE_BUTTON_CLASS
]))
{
// Bootstrap
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]);
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementName
);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$formElement
[
FE_CHECKBOX_CHECKED
],
false
);
$attribute
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]);
if
(
$formElement
[
FE_BUTTON_CLASS
]
==
''
)
{
$formElement
[
FE_BUTTON_CLASS
]
=
'btn-default'
;
}
$classActive
=
''
;
$valueJson
=
false
;
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_READONLY
)
{
$formElement
[
FE_BUTTON_CLASS
]
.
=
' disabled'
;
}
if
(
$formElement
[
FE_CHECKBOX_CHECKED
]
===
$value
)
{
$attribute
.
=
Support
::
doAttribute
(
'checked'
,
'checked'
);
$valueJson
=
$value
;
}
//$attribute .= HelperFormElement::getAttributeList($formElement, [FE_AUTOFOCUS, F_FE_DATA_PATTERN_ERROR, F_FE_DATA_REQUIRED_ERROR, F_FE_DATA_MATCH_ERROR, F_FE_DATA_ERROR]);
$attribute
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
FE_AUTOFOCUS
,
F_FE_DATA_REQUIRED_ERROR
]);
return
$this
->
constructCheckboxSingleButton
(
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
$json
);
if
(
isset
(
$formElement
[
FE_BUTTON_CLASS
]))
{
// Bootstrap
return
$this
->
constructCheckboxSingleBootstrap
(
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
$json
,
$valueJson
);
}
else
{
return
$this
->
constructCheckboxSinglePlain
(
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
$json
);
// Plain
return
$this
->
constructCheckboxSinglePlain
(
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
$json
,
$valueJson
);
}
}
...
...
@@ -432,27 +442,22 @@ class Checkbox {
* @throws \CodeException
* @throws \UserFormException
*/
public
function
constructCheckboxSingleB
utton
(
array
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
array
&
$json
)
{
public
function
constructCheckboxSingleB
ootstrap
(
array
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
array
&
$json
,
$valueJson
)
{
$html
=
''
;
$valueJson
=
false
;
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]);
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementName
);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$formElement
[
FE_CHECKBOX_CHECKED
],
false
);
$attribute
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attribute
.
=
Support
::
doAttribute
(
FE_INPUT_AUTOCOMPLETE
,
'off'
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]);
if
(
$formElement
[
FE_BUTTON_CLASS
]
==
''
)
{
$formElement
[
FE_BUTTON_CLASS
]
=
'btn-default'
;
}
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_READONLY
)
{
$formElement
[
FE_BUTTON_CLASS
]
.
=
' disabled'
;
}
$classActive
=
''
;
if
(
$formElement
[
FE_CHECKBOX_CHECKED
]
===
$value
)
{
$attribute
.
=
Support
::
doAttribute
(
'checked'
,
'checked'
);
$valueJson
=
true
;
$classActive
=
' active'
;
}
$attribute
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
'autofocus'
]);
$attribute
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
$htmlHidden
=
HelperFormElement
::
buildNativeHidden
(
$htmlFormElementName
,
$formElement
[
FE_CHECKBOX_UNCHECKED
]);
$this
->
store
->
setVar
(
$htmlFormElementName
,
$htmlHidden
,
STORE_ADDITIONAL_FORM_ELEMENTS
,
false
);
$html
=
''
;
...
...
@@ -619,8 +624,7 @@ class Checkbox {
* Create a 'hidden' input field and a 'checkbox' input field - both with the same HTML 'name'.
* HTML does not submit an unchecked checkbox. Then only the 'hidden' input field is submitted.
*
* Format: <input type="hidden" name="$htmlFormElementName" value="$valueUnChecked">
* <input name="$htmlFormElementName" type="radio" [autofocus="autofocus"]
* <input name="$htmlFormElementName" type="radio" [autofocus="autofocus"]
* [required="required"] [disabled="disabled"] value="<value>" [checked="checked"] >
*
* @param array $formElement
...
...
@@ -633,23 +637,8 @@ class Checkbox {
* @throws \CodeException
* @throws \UserFormException
*/
public
function
constructCheckboxSinglePlain
(
array
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
array
&
$json
)
{
public
function
constructCheckboxSinglePlain
(
array
$formElement
,
$htmlFormElementName
,
$attribute
,
$value
,
array
&
$json
,
$valueJson
)
{
$html
=
''
;
$valueJson
=
false
;
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]);
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementName
);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$formElement
[
FE_CHECKBOX_CHECKED
],
false
);
$attribute
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]);
if
(
$formElement
[
FE_CHECKBOX_CHECKED
]
===
$value
)
{
$attribute
.
=
Support
::
doAttribute
(
'checked'
,
'checked'
);
$valueJson
=
$value
;
}
$attribute
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
'autofocus'
]);
$attribute
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
$htmlHidden
=
HelperFormElement
::
buildNativeHidden
(
$htmlFormElementName
,
$formElement
[
FE_CHECKBOX_UNCHECKED
]);
$this
->
store
->
setVar
(
$htmlFormElementName
,
$htmlHidden
,
STORE_ADDITIONAL_FORM_ELEMENTS
,
false
);
...
...
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