File tree Expand file tree Collapse file tree
view/adminhtml/templates/form Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44namespace Loki \AdminComponents \Form \Field ;
55
66use Loki \AdminComponents \Form \Field \FieldType \Editor ;
7+ use Loki \AdminComponents \Form \Field \FieldType \Input ;
78use Magento \Framework \DataObject ;
89use Magento \Framework \View \Element \AbstractBlock ;
910use RuntimeException ;
@@ -84,6 +85,10 @@ public function getFieldAttributes(): array
8485 $ fieldAttributes ['required ' ] = null ;
8586 }
8687
88+ if ($ this ->isHidden () && $ this ->getFieldType () instanceof Input) {
89+ $ fieldAttributes ['type ' ] = 'hidden ' ;
90+ }
91+
8792 return $ fieldAttributes ;
8893 }
8994
@@ -107,4 +112,14 @@ public function isVisible(): bool
107112
108113 return true ;
109114 }
115+
116+ public function isHidden (): bool
117+ {
118+ $ hidden = $ this ->getData ('hidden ' );
119+ if (is_bool ($ hidden )) {
120+ return $ hidden ;
121+ }
122+
123+ return false ;
124+ }
110125}
Original file line number Diff line number Diff line change @@ -34,13 +34,20 @@ if (false === $field->isVisible()) {
3434 return ;
3535}
3636
37+ $ cssClass [] = 'admin__field ' ;
38+ if ($ field ->isHidden ()) {
39+ $ cssClass [] = 'hidden ' ;
40+ }
41+
3742$ depends = $ field ->getDepends ();
3843$ dependStatement = '' ;
3944if (!empty ($ depends )) {
4045 $ dependStatement = 'x-show="item. ' .$ depends ['propertyName ' ] . " == ' " .$ depends ['propertyValue ' ]."' \"" ;
4146}
47+
48+ $ cssClass = implode (' ' , $ cssClass );
4249?>
43- <div class="admin__field " <?= $ escaper ->escapeHtml ($ dependStatement ) ?> >
50+ <div class="<?= $ cssClass ?> " <?= $ escaper ->escapeHtml ($ dependStatement ) ?> >
4451 <div class="admin__field-label">
4552 <label for="<?= $ escaper ->escapeHtml ($ field ->getCode ()) ?> ">
4653 <span><?= $ escaper ->escapeHtml ($ field ->getLabel ()) ?> </span>
Original file line number Diff line number Diff line change 11<?php
22declare (strict_types=1 );
33
4- /** @version 0.5.1 */
5-
64use Magento \Framework \Escaper ;
75use Magento \Framework \View \Element \Template ;
86use Loki \AdminComponents \Form \Field \Field ;
97use Loki \AdminComponents \Form \Field \FieldType \Input ;
108use Loki \Components \Util \Block \TemplateRenderer ;
119
10+ /** @version 0.5.1 */
1211/** @var Escaper $escaper */
1312/** @var Template $block */
1413/** @var Field $field */
You can’t perform that action at this time.
0 commit comments