Form is submitting the Array instead of the wanted

2019-08-27 19:41发布

问题:

I am new to cake and I am trying to learn its philosophy. So I am trying to create a form "Movie" as follows and my database accepts movie_id, title, year, and description. When I run the code it tries to store the "array" as the year input. This is the error I get => movie_id, title, year, description) VALUES (NULL, 'Movie1', Array, 'some text')

THE VIEW:

   <?php echo $this->Form->create('Movie'); ?>
    <?php echo __('Add Movie'); ?>

     <?php
        echo $this->Form->hidden('movie_id');

        echo $this->Form->input('title');

         echo $this->Form->input('year', array(
            'type'=>'date',
            'dateFormat'=>'Y',
            'minYear'=>'1990',
            'maxYear'=>date('Y'),
        ));

        echo $this->Form->input('description');

        ?>

<?php echo $this->Form->end(__('Submit')); 

?>

THE CONTROLLER:

public function add() {

if ($this->request->is('post')) {

    $this->Movie->create();

      if ($this->Movie->save($this->request->data)) {
        $this->Session->setFlash(__('The movie has been created'));
        $this->redirect (array('action'=>'index'));
      } 

      else {

        $this->Session->setFlash(__('The movie could not be created. Please, try again.'));

      }
}
}

As I said I am new to cake so my apologies if this question sounds stupid, please give your solution. Thanks