<form method="<?php echo $this->form->getMethod(); ?>" action="<?php echo $this->form->getAction(); ?>" class="form-horizontal">
    <?php echo $this->form->hiddenElements; ?>
    <div class="table-responsive">
        <table class="table">
            <thead>
                <tr>
                    <th class="size-small">Payment Gateway</th>
                    <th>Settings</th>
                    <th class="size-mini">Site Fees</th>
                    <th class="size-mini">Direct Payment</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $checkboxCounter = 0;
                foreach ((array) $this->form->getData() as $data) { ?>
                <tr>
                    <td>
                        <img src="<?php echo $this->baseUrl . $data['logo_path']; ?>" alt="<?php echo $data['name']; ?>">
                    </td>
                    <td>
                        <?php
                        foreach ($this->formElements as $element) {
                            if ($element['form_id'] == $data['name']) {

                                $element = $this->form->getElement($element['id']);
                                $label = $element->getLabel();
                                $description = $element->getDescription();
                                $elementName = $element->getName();

                                if (isset($data[$elementName])) {
                                    $element->setData($data[$elementName]);
                                }

                                $element->setBrackets('[' . $data['id'] . ']')->setMultiple();

                                echo $this->partial('partials/form-element.phtml', array('element' => $element));
                            }
                        } ?>
                    </td>
                    <td>
                        <?php echo $this->form->getElement('site_fees')
                                ->setData($data['site_fees'])
                                ->setBrackets('[' . $checkboxCounter . ']')
                                ->render(); ?>
                    </td>
                    <td>
                        <?php echo $this->form->getElement('direct_payment')
                                ->setData($data['direct_payment'])
                                ->setBrackets('[' . $checkboxCounter . ']')
                                ->render(); ?>
                        <?php echo $this->form->getElement('id')->setData($data['id'])->render(); ?>
                    </td>
                </tr>
                <?php $checkboxCounter ++; ?>
                <?php } ?>
                <tr>
                    <td colspan="4"><?php echo $this->form->getElement('submit')->render(); ?></td>
                </tr>
            </tbody>
        </table>
    </div>
</form>