44
55use Loki \AdminComponents \Form \Field \Field ;
66use Loki \AdminComponents \Form \Field \FieldFactory ;
7+ use Loki \AdminComponents \Form \Fieldset \Fieldset ;
8+ use Loki \AdminComponents \Form \Fieldset \FieldsetFactory ;
9+ use Loki \AdminComponents \Ui \Button ;
10+ use Loki \AdminComponents \Ui \ButtonFactory ;
711use Magento \Framework \View \Element \AbstractBlock ;
12+ use Magento \Framework \View \LayoutInterface ;
813
914class FormBuilder
1015{
1116 public function __construct (
1217 private FormFactory $ formFactory ,
13- private FieldFactory $ fieldFactory
18+ private FieldFactory $ fieldFactory ,
19+ private FieldsetFactory $ fieldsetFactory ,
20+ private ButtonFactory $ buttonFactory ,
21+ private LayoutInterface $ layout
1422 ) {
1523 }
1624
@@ -19,8 +27,28 @@ public function createForm(string $code): Form
1927 return $ this ->formFactory ->create ($ code );
2028 }
2129
22- public function createField (AbstractBlock $ block , array $ data = []): Field
30+ public function createField (array $ data = []): Field
2331 {
32+ $ block = $ this ->layout ->createBlock (AbstractBlock::class);
2433 return $ this ->fieldFactory ->create ($ block , $ data );
2534 }
35+
36+ public function createFieldset (string $ code , string $ label = '' , array $ fields = []): Fieldset
37+ {
38+ return $ this ->fieldsetFactory ->create ($ code , $ label , $ fields );
39+ }
40+
41+ public function createButton (
42+ string $ method ,
43+ string $ label ,
44+ string $ cssClass = '' ,
45+ string $ url = '' ,
46+ array $ subButtons = [],
47+ bool $ primary = false ,
48+ ): Button
49+ {
50+ return $ this ->buttonFactory ->create (
51+ $ method , $ label , $ cssClass , $ url , $ subButtons , $ primary
52+ );
53+ }
2654}
0 commit comments