CI 4 - <select>、<option> 列 'zeme_idZeme' 不能为空

CI 4 - <select>, <option> Column 'zeme_idZeme' cannot be null

它向我显示此错误:列 'zeme_idZeme' 不能为空 我以为 <select name="zeme_IdZeme"> 这就足够了,但我错了。 查看:

<body>
    <div class="main-block">
      <h1>Film</h1>
      <form method="post" action="<?php echo base_url('/form') ?>">
        <div class="info">
          <input type="text" name="cesky_nazev" required="vyžadováno" placeholder="Český název filmu">
          <input type="text" name="originalni_nazev" required="vyžadováno" placeholder="Původní název filmu">
          <input type="number" name="delka_filmu" required="vyžadováno" placeholder="Délka filmu">
          <input type="text" name="typ_filmu" required="vyžadováno" placeholder="Typ filmu">
          
          <select name="zeme_IdZeme">
            <option disabled selected>Země</option>
            <?php
            $query = $db->query("SELECT * FROM zeme");
            foreach ($query->getResult() as $row)
            { ?> 
         <option value="5"> <?php echo $row->nazev;}?></option>
          </select>

 

        </div>
        <button type="submit" class="button">Odeslat</button>
      </form>
    </div>
  </body>

控制器:

    public function form() {
        $data = [ 'cesky_nazev' =>$this->request->getVar('cesky_nazev'),
        'originalni_nazev' =>$this->request->getVar('originalni_nazev'),
        'delka_filmu' =>$this->request->getVar('delka_filmu'),
        'typ_filmu' =>$this->request->getVar('typ_filmu'),
        'zeme_idZeme' =>$this->request->getVar('zeme_idZeme'),
        'zanrFilmu_idZanrFilmu' =>$this->request->getVar('zanrFilmu_idZanrFilmu'),
        'promitani_idPromitani' =>$this->request->getVar('promitani_idPromitani'),
        'jazyky_idJazyky' =>$this->request->getVar('jazyky_idJazyky') ];

        
        /*
        $db =  \Config \Database::connect();
        $builder = $db->table('film');
        $builder->insert($data); */

        $model = new Film_formular();
        if ($model->insert($data))
        {
            echo view('templates/header');
            ?><style>.center {text-align: center;color: red;}</style><?php
            echo "<h3 class='center'>Úspěšně přidáno</h3>";
            echo view('film_formular');
            echo view('templates/footer');
        }
        else 
        {
            echo "nepřidáno";
        }
    

}

型号:

<?php namespace App\Models;

use CodeIgniter\Model;

class Film_formular extends Model
{
    protected $table      = 'film';
    protected $allowedFields = ['cesky_nazev', 'originalni_nazev', 'delka_filmu', 'typ_filmu', 'zeme_idZeme', 'zanrFilmu_idZanrFilmu','promitani_idPromitani','jazyky_idJazyky'];


}

选项关闭标记不在 foreach 中。在选项关闭标记后移动括号

<select name="zeme_IdZeme">
  <option disabled selected>Země</option>
  <?php
  $query = $db->query("SELECT * FROM zeme");
  foreach ($query->getResult() as $row)
  { 
  ?> 
    <option value="5"> <?php echo $row->nazev;?></option>
  <?php 
  } 
  ?> </select>