Skip to content

Commit 1d1fb86

Browse files
AndreasMueller75mam08ixo
authored andcommitted
DHLGW-1165: add interactive shipping settings form
1 parent 341fdd0 commit 1d1fb86

File tree

19 files changed

+583
-210
lines changed

19 files changed

+583
-210
lines changed

Block/Adminhtml/Confirm/Form.php

Lines changed: 0 additions & 141 deletions
This file was deleted.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
declare(strict_types=1);
88

9-
namespace Netresearch\InteractiveBatchProcessing\Block\Adminhtml;
9+
namespace Netresearch\InteractiveBatchProcessing\Block\Adminhtml\Container;
1010

1111
use Magento\Backend\Block\Widget\Form\Container;
1212

13+
/**
14+
* The form container that holds the form widget.
15+
*/
1316
class Confirm extends Container
1417
{
1518
/**
@@ -20,10 +23,12 @@ class Confirm extends Container
2023
protected function _construct()
2124
{
2225
$this->_controller = 'adminhtml';
23-
$this->_mode = 'confirm';
26+
$this->_mode = 'widget';
2427
$this->_blockGroup = 'Netresearch_InteractiveBatchProcessing';
2528

2629
parent::_construct();
30+
31+
$this->removeButton('reset');
2732
}
2833

2934
public function getBackUrl()
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/**
4+
* See LICENSE.md for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Netresearch\InteractiveBatchProcessing\Block\Adminhtml\Data\Form;
10+
11+
use Magento\Framework\Data\Form;
12+
use Magento\Framework\Data\Form\Element\Fieldset;
13+
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Framework\Profiler;
15+
16+
class Confirm extends Form
17+
{
18+
private function getTableHtml(): string
19+
{
20+
$tHead = '';
21+
22+
$first = $this->getElements()->offsetGet(0);
23+
if ($first instanceof Fieldset) {
24+
$tHead .= '<thead><tr>';
25+
foreach ($first->getChildren() as $child) {
26+
$tHead .= sprintf(
27+
'<th class="%s" scope="col"><span>%s</span></th>',
28+
$child->getData('class'),
29+
$child->getData('label')
30+
);
31+
}
32+
$tHead .= '</tr></thead>';
33+
}
34+
35+
$tBody = '<tbody>';
36+
foreach ($this->getElements() as $element) {
37+
$tBody .= $element->toHtml();
38+
}
39+
$tBody.= '</tbody>';
40+
41+
return '<table class="data-table admin__table-primary">' . $tHead . $tBody . '</table>';
42+
}
43+
44+
/**
45+
* @return string
46+
* @throws LocalizedException
47+
*/
48+
public function toHtml()
49+
{
50+
Profiler::start('form/toHtml');
51+
$html = '';
52+
$useContainer = $this->getUseContainer();
53+
if ($useContainer) {
54+
$html .= '<form ' . $this->serialize($this->getHtmlAttributes()) . '>';
55+
$html .= '<div>';
56+
if (strtolower($this->getData('method')) == 'post') {
57+
$html .= '<input name="form_key" type="hidden" value="' . $this->formKey->getFormKey() . '" />';
58+
}
59+
$html .= '</div>';
60+
}
61+
62+
$html .= $this->getTableHtml();
63+
64+
if ($useContainer) {
65+
$html .= '</form>';
66+
}
67+
Profiler::stop('form/toHtml');
68+
return $html;
69+
}
70+
}

0 commit comments

Comments
 (0)