添加表单不会将记录添加到数据库

时间:2019-06-17 15:20:51

标签: cakephp-3.0 cakephp-3.7

我是Cakephp的新手。我正在尝试创建一个应用程序,但遇到了问题。当我尝试导入一些模板以使用其表单向数据库添加或更新记录时,它不会,并且当我放置一个没有属性的简单表单时,它会起作用。为什么?有人帮我

此功能无效

<div class="wrap-contact100">
  <form class="contact100-form validate-form">
    <?= $this->Form->create($contact) ?>
      <span class="contact100-form-title">
        Send Us A Message
      </span>
      <div class="wrap-input100 validate-input" data-validate="Please enter your name">
        <?php echo $this->Form->control('nom_prenom',array('class'=>'input100','type'=>'text','name'=>'name','placeholder'=>'Nom et prénom')); ?>
        <span class="focus-input100"></span>
      </div>
      <div class="wrap-input100 validate-input" data-validate="Please enter your email: e@a.x">
        <?php echo $this->Form->control('email',array('class'=>'input100','type'=>'text','name'=>'email','placeholder'=>'E-mail')); ?>
        <span class="focus-input100"></span>
      </div>
      <div class="wrap-input100 validate-input" data-validate="Please enter your phone">
        <?php echo $this->Form->control('telephone',array('class'=>'input100','type'=>'text','name'=>'phone','placeholder'=>'Tel')); ?>
        <span class="focus-input100"></span>
      </div>
      <div class="wrap-input100 validate-input" data-validate="Please enter your phone">
        <?php echo $this->Form->control('sujet',array('class'=>'input100','type'=>'text','name'=>'sujet','placeholder'=>'Sujet')); ?>
        <span class="focus-input100"></span>
      </div>
      <div class="wrap-input100 validate-input" data-validate="Please enter your message">
        <?php echo $this->Form->control('description',array('class'=>'input100','type'=>'text','name'=>'des','placeholder'=>'Message')); ?>
        <span class="focus-input100"></span>
      </div>
      <div class="container-contact100-form-btn">
        <?= $this->Form->button(__('Submit'),array('class'=>'contact100-form-btn')) ?>
        <?= $this->Form->end() ?>
      </div>
  </form>
</div>
</div>

,这一项有效

<div class="contact form large-9 medium-8 columns content">
  <?= $this->Form->create($contact) ?>
    <fieldset>
      <legend>
        <?= __('Add Contact') ?>
      </legend>
      <?php
                echo $this->Form->control('nom_prenom');
                echo $this->Form->control('email');
                echo $this->Form->control('telephone');
                echo $this->Form->control('sujet');
                echo $this->Form->control('description');
            ?>
    </fieldset>
    <?= $this->Form->button(__('Submit')) ?>
    <?= $this->Form->end() ?>
</div>
</div>

0 个答案:

没有答案