在CakePHP中提交表单时未插入数据

时间:2016-06-16 00:29:46

标签: php forms cakephp

当我点击添加页面表单上的提交按钮时,我的数据未提交。下面是我的代码。非常感谢任何帮助..这是我的控制器功能:

public function add()
{
    $complejo = $this->Complejos->newEntity();
    if ($this->request->is('complejo')) {
        $complejo = $this->Complejos->patchEntity($complejo, $this->request->data);
        if ($this->Complejos->save($complejo)) {
            $this->Flash->success(__('El complejo se ha guardado con éxito.'));
            return $this->redirect(['action' => 'index']);
        } else {
            $this->Flash->error(__('El complejo no se ha guardado. Por favor intente de nuevo.'));
        }
    }

    $ciudades = $this->Complejos->Ciudades->find('list', ['limit' => 200]);
    $this->set(compact('complejo', 'ciudades'));
    $this->set('_serialize', ['complejo']);
}

这是我的add.ctp

    <nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
    <li class="heading"><?= __('Actions') ?></li>
    <li><?= $this->Html->link(__('List Complejos'), ['action' => 'index']) ?></li>
</ul>
</nav>
<div class="posts form large-9 medium-8 columns content">
<?= $this->Form->create($complejo) ?>
<fieldset>
    <legend><?= __('Agregar Complejo') ?></legend>
    <?php
        echo $this->Form->input('nombre');
        echo $this->Form->input('descripcion');
        echo $this->Form->input('ciudadFK', ['options' => $ciudades]);
        echo $this->Form->input('nombreUsuario');
        echo $this->Form->input('contrasenia');
        echo $this->Form->input('direccion');
        echo $this->Form->input('latitud');
        echo $this->Form->input('longitud');
        echo $this->Form->input('telefono');
        echo $this->Form->input('telefono2');
        echo $this->Form->input('vestuario', array('options' => array('Si'=>'Si', 'No'=>'No')));
        echo $this->Form->input('asador', array('options' => array('Si'=>'Si', 'No'=>'No')));
        echo $this->Form->input('estacionamiento', array('options' => array('Si'=>'Si', 'No'=>'No')));
        echo $this->Form->input('requiereSenia', array('options' => array('1'=>'Si', '0'=>'No')));
        echo $this->Form->input('horaDisponible');
        echo $this->Form->input('tiempoReserva');

    ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>

点击提交时没有任何反应。 感谢

1 个答案:

答案 0 :(得分:1)

AS @AIPDTECH说:

我必须更改我的控制器:

new SitemapItem(Url.QualifiedAction("index", "home"), changeFrequency: SitemapChangeFrequency.Always, priority: 1.0),