Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
typo3
qfq
Commits
6557e683
Commit
6557e683
authored
5 years ago
by
Carsten Rose
Browse files
Options
Downloads
Patches
Plain Diff
Checkbox Multi Button: dynamic update scheint ok zu sein.
parent
91ae89f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!221
B9720 checkbox various setups
Pipeline
#2970
failed
5 years ago
Stage: before
Stage: build
Stage: selenium
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extension/Classes/Core/Form/Checkbox.php
+45
-75
45 additions, 75 deletions
extension/Classes/Core/Form/Checkbox.php
with
45 additions
and
75 deletions
extension/Classes/Core/Form/Checkbox.php
+
45
−
75
View file @
6557e683
...
...
@@ -16,13 +16,13 @@ namespace IMATHUZH\Qfq\Core\Form;
//use IMATHUZH\Qfq\Core\Helper\Logger;
//use IMATHUZH\Qfq\Core\Helper\OnArray;
//use IMATHUZH\Qfq\Core\Helper\Sanitize;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
use
IMATHUZH\Qfq\Core\Store\Store
;
//use IMATHUZH\Qfq\Core\Report\Link;
//use IMATHUZH\Qfq\Core\Report\Report;
//use IMATHUZH\Qfq\Core\Store\Sip;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
TYPO3\PharStreamWrapper\Helper
;
/**
...
...
@@ -101,7 +101,7 @@ class Checkbox {
$attributeBase
=
HelperFormElement
::
getAttributeFeMode
(
$formElement
[
FE_MODE
]);
$attributeBase
.
=
Support
::
doAttribute
(
'type'
,
$formElement
[
FE_TYPE
]);
$attributeBase
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_
PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA
_ERROR
]);
$attributeBase
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_
REQUIRED
_ERROR
]);
switch
(
$formElement
[
'checkBoxMode'
])
{
case
'single'
:
...
...
@@ -178,6 +178,7 @@ class Checkbox {
if
(
$formElement
[
FE_BUTTON_CLASS
]
==
''
)
{
$formElement
[
FE_BUTTON_CLASS
]
=
'btn-default'
;
}
$formElement
[
FE_BUTTON_CLASS
]
=
'btn '
.
$formElement
[
FE_BUTTON_CLASS
];
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_READONLY
)
{
$formElement
[
FE_BUTTON_CLASS
]
.
=
' disabled'
;
...
...
@@ -194,7 +195,6 @@ class Checkbox {
*
* Layout: The Bootstrap Layout needs very special setup, the checkboxes are wrapped differently with <div
* class=checkbox> depending of if they aligned horizontal or vertical.
*
* @param array $formElement
* @param string $htmlFormElementName
* @param string $attributeBase
...
...
@@ -214,27 +214,30 @@ class Checkbox {
$values
=
explode
(
','
,
$value
);
$attributeBase
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attributeBase
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
$key
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
'h'
,
true
);
$htmlHidden
=
HelperFormElement
::
buildNativeHidden
(
$key
,
''
);
$this
->
fillStoreAdditionalFormElementsCheckboxHidden
(
$formElement
,
$htmlFormElementName
,
$htmlHidden
);
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_READONLY
)
{
$attributeBase
.
=
Support
::
doAttribute
(
'disabled'
,
'disabled'
);
}
$html
=
''
;
$attribute
=
$attributeBase
;
if
(
isset
(
$formElement
[
FE_AUTOFOCUS
]))
{
$attribute
.
=
Support
::
doAttribute
(
'autofocus'
,
$formElement
[
FE_AUTOFOCUS
]);
}
// Used in getFormElementForJson() for dynamic update.
$labelBaseClass
=
$formElement
[
FE_BUTTON_CLASS
];
for
(
$ii
=
0
,
$jj
=
1
;
$ii
<
count
(
$itemKey
);
$ii
++
,
$jj
++
)
{
$attribute
=
$attributeBase
;
$jsonValue
=
false
;
$classActive
=
''
;
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
,
true
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]
.
'-'
.
$ii
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
HelperFormElement
::
getCheckboxRadioOptionId
(
$formElement
[
FE_HTML_ID
]
,
$ii
)
)
;
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementNameUniq
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]
.
'-'
.
$ii
);
if
(
isset
(
$formElement
[
FE_AUTOFOCUS
]))
{
$attribute
.
=
Support
::
doAttribute
(
'autofocus'
,
$formElement
[
FE_AUTOFOCUS
]);
unset
(
$formElement
[
FE_AUTOFOCUS
]);
}
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
],
false
);
...
...
@@ -250,13 +253,13 @@ class Checkbox {
$htmlElement
=
'<input '
.
$attribute
.
'>'
.
$value
;
$html
.
=
Support
::
wrapTag
(
"<label class='btn "
.
$formElement
[
FE_BUTTON_CLASS
]
.
"
$classActive
'>"
,
$checkboxLabelId
=
HelperFormElement
::
getCheckboxRadioOptionId
(
$formElement
[
FE_HTML_ID
],
$ii
,
HTML_ID_EXTENSION_LABEL
);
$html
.
=
Support
::
wrapTag
(
"<label class='"
.
$formElement
[
FE_BUTTON_CLASS
]
.
"
$classActive
' id=
\"
$checkboxLabelId
\"
>"
,
$htmlElement
,
true
);
$
json
[]
=
$this
->
getFormElementForJsonCheckBox
(
$htmlFormElementNameUniq
,
$jsonValue
,
$formElement
)
;
$
formElement
[
FE_TMP_CLASS_OPTION
]
=
$labelBaseClass
.
$classActive
;
// Init for the next checkbox
$attribute
=
$attributeBase
;
$json
[]
=
$this
->
getFormElementForJsonCheckBox
(
$htmlFormElementNameUniq
,
$jsonValue
,
$formElement
,
$ii
);
}
$html
=
Support
::
wrapTag
(
'<div class="btn-group" data-toggle="buttons">'
,
$html
);
...
...
@@ -270,6 +273,21 @@ class Checkbox {
* Layout: The Bootstrap Layout needs very special setup, the checkboxes are wrapped differently with <div
* class=checkbox> depending of if they aligned horizontal or vertical.
*
* <div class="col-md-6" required="required">
* <label class="checkbox-inline" id="1039-21332-1-0-0-l">
* <input checked="checked" id="1039-21332-1-0-0" name="groups-1[]" required="required" type="checkbox" value="1">
* label1
* <span aria="hidden" class="checkmark"></span>
* </label>
*
* <label class="checkbox-inline" id="1039-21332-1-0-2-l">
* <input id="1039-21332-1-2-0" name="groups-1[]"
* required="required" type="checkbox" value="2">
* label2
* <span aria="hidden" class="checkmark"></span>
* </label>
* </div>
*
* @param array $formElement
* @param string $htmlFormElementName
* @param string $attributeBase
...
...
@@ -289,14 +307,8 @@ class Checkbox {
$values
=
explode
(
','
,
$value
);
$attributeBase
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attributeBase
.
=
HelperFormElement
::
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
// 'font-weight: 400;': class 'checkbox' forces bold for the label - this is not ok.
$attributeBaseLabel
=
Support
::
doAttribute
(
'style'
,
'min-width: '
.
$formElement
[
F_FE_MIN_WIDTH
]
.
'px; font-weight: 400;'
);
// $key = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, 'h');
// $htmlHidden = HelperFormElement::buildNativeHidden($key, '');
// $this->fillStoreAdditionalFormElementsCheckboxHidden($formElement, $htmlFormElementName, $htmlHidden);
$attributeBaseLabel
=
Support
::
doAttribute
(
'style'
,
'min-width: '
.
$formElement
[
F_FE_MIN_WIDTH
]
.
'px;'
);
$html
=
''
;
...
...
@@ -305,26 +317,23 @@ class Checkbox {
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_READONLY
)
{
$checkboxClass
.
=
' qfq-disabled'
;
// necessary for own style checkboxes to display them 'disabled'
}
// Used in getFormElementForJson() for dynamic update.
$formElement
[
FE_TMP_CLASS_OPTION
]
=
$checkboxClass
;
$br
=
''
;
$flagFirst
=
true
;
for
(
$ii
=
0
,
$jj
=
1
;
$ii
<
count
(
$itemKey
);
$ii
++
,
$jj
++
)
{
$jsonValue
=
false
;
$attribute
=
$attributeBase
;
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
,
true
);
$checkboxId
=
HelperFormElement
::
getCheckboxRadioOptionId
(
$formElement
[
FE_HTML_ID
],
$ii
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$checkboxId
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
HelperFormElement
::
getCheckboxRadioOptionId
(
$formElement
[
FE_HTML_ID
],
$ii
));
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementNameUniq
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]
.
'-'
.
$ii
);
// Do this only the first round.
if
(
$flagFirst
)
{
$flagFirst
=
false
;
if
(
isset
(
$formElement
[
FE_AUTOFOCUS
]))
$attribute
.
=
Support
::
doAttribute
(
'autofocus'
,
$formElement
[
FE_AUTOFOCUS
]);
if
(
isset
(
$formElement
[
FE_AUTOFOCUS
]))
{
$attribute
.
=
Support
::
doAttribute
(
'autofocus'
,
$formElement
[
FE_AUTOFOCUS
]);
unset
(
$formElement
[
FE_AUTOFOCUS
]);
}
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
],
false
);
...
...
@@ -340,11 +349,6 @@ class Checkbox {
$htmlElement
=
'<input '
.
$attribute
.
'>'
.
$value
;
// With ALIGN_HORIZONTAL: the label causes some trouble: skip it
// if (($orientation === ALIGN_VERTICAL)) {
// $htmlElement = Support::wrapTag('<label>', $htmlElement);
// }
$checkboxLabelId
=
HelperFormElement
::
getCheckboxRadioOptionId
(
$formElement
[
FE_HTML_ID
],
$ii
,
HTML_ID_EXTENSION_LABEL
);
$htmlElement
=
Support
::
wrapTag
(
"<label class=
\"
$checkboxClass
\"
$attributeBaseLabel
id=
\"
$checkboxLabelId
\"
>"
,
$htmlElement
,
true
);
...
...
@@ -360,7 +364,7 @@ class Checkbox {
}
$html
.
=
$htmlElement
.
$br
;
$json
[]
=
$this
->
getFormElementForJsonCheckbox
(
$htmlFormElementNameUniq
,
$jsonValue
,
$formElement
,
$ii
,
$checkboxClass
);
$json
[]
=
$this
->
getFormElementForJsonCheckbox
(
$htmlFormElementNameUniq
,
$jsonValue
,
$formElement
,
$ii
);
}
...
...
@@ -502,12 +506,11 @@ class Checkbox {
* @param array $formElement
*
* @param int $optionIdx
* @param string $class
* @return array
* @throws \CodeException
* @throws \UserFormException
*/
private
function
getFormElementForJsonCheckBox
(
$htmlFormElementName
,
$value
,
array
$formElement
,
$optionIdx
=
0
,
$optionClass
=
''
)
{
private
function
getFormElementForJsonCheckBox
(
$htmlFormElementName
,
$value
,
array
$formElement
,
$optionIdx
=
0
)
{
$addClassRequired
=
array
();
$json
=
HelperFormElement
::
getJsonFeMode
(
$formElement
[
FE_MODE
]);
// disabled, required
...
...
@@ -521,18 +524,10 @@ class Checkbox {
}
$statusHidden
=
(
$formElement
[
FE_MODE
]
==
'hidden'
);
$pattern
=
null
;
if
(
isset
(
$formElement
[
FE_CHECK_PATTERN
])
&&
$formElement
[
FE_CHECK_PATTERN
]
!=
''
)
{
$pattern
=
$statusHidden
?
false
:
$formElement
[
FE_CHECK_PATTERN
];
}
// 'value' update via 'form-update' on the full row: only if there is no other FE in that row
if
(
$flagRowUpdate
)
{
$json
[
API_FORM_UPDATE_VALUE
]
=
$value
;
//CR if ($pattern !== null) {
// $json['pattern'] = $pattern;
// }
}
if
(
$formElement
[
FE_MODE
]
==
FE_MODE_REQUIRED
||
$formElement
[
FE_MODE
]
==
FE_MODE_SHOW_REQUIRED
)
{
...
...
@@ -558,15 +553,9 @@ class Checkbox {
if
(
isset
(
$formElement
[
FE_TYPE
]))
{
$key
=
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_INPUT
;
// For FE.type='note': update the column 'input'
if
(
$formElement
[
FE_TYPE
]
===
FE_TYPE_NOTE
)
{
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_CONTENT
]
=
$value
;
}
// Check show/hide: only FE with FE_MODE_SQL given, might change.
if
(
!
empty
(
$formElement
[
FE_MODE_SQL
]))
{
$class
=
is_numeric
(
$formElement
[
FE_BS_INPUT_COLUMNS
])
?
(
'col-md-'
.
$formElement
[
FE_BS_INPUT_COLUMNS
])
:
$formElement
[
FE_BS_INPUT_COLUMNS
];
// $class = 'col-md-' . $formElement[FE_BS_INPUT_COLUMNS] . ' ';
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_ATTRIBUTE
][
'required'
]
=
(
$formElement
[
FE_MODE
]
==
'required'
);
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_ATTRIBUTE
][
'hidden'
]
=
$statusHidden
;
...
...
@@ -589,25 +578,6 @@ class Checkbox {
$class
.
=
(
$formElement
[
FE_MODE
]
==
FE_MODE_HIDDEN
)
?
' hidden'
:
''
;
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_ATTRIBUTE
][
'class'
]
=
$class
;
if
(
$pattern
!==
null
)
{
$json
[
API_ELEMENT_UPDATE
][
$key
][
API_ELEMENT_ATTRIBUTE
][
'pattern'
]
=
$pattern
;
}
}
// #3647
// if (!$flagRowUpdate) {
// #4771 - temporary workaround: SELECT in 'multi FE row' won't updated after 'save' or with dynamic update.
//TODO #5016 - exception for FE_TYPE_CHECKBOX should be removed ASAP
if
(
$formElement
[
FE_TYPE
]
!=
FE_TYPE_SELECT
&&
$formElement
[
FE_TYPE
]
!=
FE_TYPE_UPLOAD
&&
$formElement
[
FE_TYPE
]
!=
FE_TYPE_CHECKBOX
)
{
$json
[
API_ELEMENT_UPDATE
][
$formElement
[
FE_HTML_ID
]][
API_ELEMENT_ATTRIBUTE
][
'value'
]
=
$value
;
$json
[
API_ELEMENT_UPDATE
][
$formElement
[
FE_HTML_ID
]][
API_ELEMENT_ATTRIBUTE
][
'required'
]
=
(
$formElement
[
FE_MODE
]
==
'required'
);
$json
[
API_ELEMENT_UPDATE
][
$formElement
[
FE_HTML_ID
]][
API_ELEMENT_ATTRIBUTE
][
'hidden'
]
=
$statusHidden
;
if
(
$pattern
!==
null
)
{
$json
[
API_ELEMENT_UPDATE
][
$formElement
[
FE_HTML_ID
]][
API_ELEMENT_ATTRIBUTE
][
'pattern'
]
=
$pattern
;
}
}
}
...
...
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