<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
  <link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
  <?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
  <div class="action_form">
    <table class="table table-bordered">
      <?php $cnt = 1 ?>
      <?php foreach ($viewDatas['fields'] as $field): ?>
        <tr>
          <th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
          <td nowrap class="text-start">
            <?php
            $extras = ["class" => 'form-control'];
            if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
              $extras = ["required" => "", ...$extras];
            }
            ?>
            <?= $viewDatas['helper']->getFieldForm($field,  old($field) ?? $viewDatas['entity']->$field, $viewDatas, $extras) ?>
            <div><?= validation_show_error($field); ?></div>
          </td>
          <?php $cnt++ ?>
        </tr>
      <?php endforeach; ?>
      <tr>
        <td colspan="<?= $cnt * 2 ?>" class="text-center">
          <?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?>
        </td>
      </tr>
    </table>
    <?= form_close(); ?>
  </div>
</div>
<?= $this->endSection() ?>