Problema con date_field

edited octubre 2010 in Principiantes
Hola , tengo un problema al ingresar la fecha con este helper date_field , no me registra nada en la base de datos y no se que hacer ya que aparentemente todo esta bien . Estoy usando la ver de kumbia 0.5 y base de datos mysql .
Este es el codigo de mi formulario
<?php echo form_tag('usuario/create/') ?>
<table>
<tr>
<td>Nombres :</td>
<td><?php echo text_field_tag(array('usuario.Nombres')) ?></td>
</tr>
<tr>
<td>Apellidos :</td>
<td><?php echo text_field_tag(array('usuario.Apellidos')) ?></td>
</tr>
<tr>
<td>Fecha de nacimiento :</td>
<td><?php echo date_field_tag(array('usuario.Fechan')) ?></td>
</tr>
<tr>
<td>Dni :</td>
<td><?php echo numeric_field_tag(array('usuario.Dni')) ?></td>
</tr>
<tr>
<td>Fecha de ingreso :</td>
<td><?php echo date_field_tag(array('usuario.Fechai')) ?></td>
</tr>
<tr>
<td>Dirección :</td>
<td><?php echo text_field_tag(array('usuario.Direccion')) ?></td>
</tr>
<tr>
<td>Telefono :</td>
<td><?php echo numeric_field_tag(array('usuario.Telefono')) ?></td>
</tr>
<tr>
<td>Usuario :</td>
<td><?php echo text_field_tag(array('usuario.Usuario')) ?></td>
</tr>
<tr>
<td>Password :</td>
<td><?php echo password_field_tag(array('usuario.Password')) ?></td>
</tr>
<tr>
<td>Email :</td>
<td><?php echo text_field_tag(array('usuario.Email')) ?></td>
</tr>

<tr>
<td>Perfil:</td>
<td><? echo select_tag(array('usuario.Perfil_Id')) ?>
<? echo option_tag("0", "Seleccione una..." , "selected: true" ) ?>
<? $perfil = new Perfil(); foreach($perfil->find() as $per): ?>
<? echo option_tag($per->Id, $per->Nombre) ?>
<? endforeach; ?>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><?php echo submit_tag('Agregar') ?></td>
</tr>
</table>
<?php echo end_form_tag() ?>

Si alguien me podria decir cual es el problema , se lo agradeceria mucho

Comentarios

  • ...Y cual es la estructura de la BD?
  • edited 8:10
    ...Y cual es la estructura de la BD?

    Hola gracias por responder, la estructura de la tabla de la bd es esta


    CREATE TABLE IF NOT EXISTS `usuario` (
    `Id` int(11) NOT NULL AUTO_INCREMENT,
    `Nombres` varchar(45) NOT NULL,
    `Apellidos` varchar(45) NOT NULL,
    `Fechan` date NOT NULL,
    `Dni` varchar(10) NOT NULL,
    `Fechai` date NOT NULL,
    `Direccion` varchar(80) NOT NULL,
    `Telefono` varchar(15) NOT NULL,
    `Usuario` varchar(25) NOT NULL,
    `Password` varchar(25) NOT NULL,
    `Perfil_Id` int(11) DEFAULT NULL,
    PRIMARY KEY (`Id`),
    KEY `fk_Usuario_Perfil` (`Perfil_Id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
  • tabién deberías colocar el controller donde procesas el form...
  • edited 8:10
    este es el metodo del controller

    public function create ()
    {
    /**
    * Se verifica si el usuario envio el form (submit) y si ademas
    * dentro del array POST existe uno llamado "menus"
    * el cual aplica la autocarga de objeto para guardar los
    * datos enviado por POST utilizando autocarga de objeto
    */
    if($this->has_post('usuario')){
    /**
    * se le pasa al modelo por constructor los datos del form y ActiveRecord recoge esos datos
    * y los asocia al campo correspondiente siempre y cuando se utilice la convención
    * model.campo
    */
    $usuario = new Usuario($this->post('usuario'));
    //En caso que falle la operación de guardar

    $nombre_usuario = $this->request('usuario.Usuario');
    if(!$this->Usuario->find_first("Usuario = '$nombre_usuario' ")){

    if(!$usuario->save()){
    Flash::error('Falló Operación');
    //se hacen persistente los datos en el formulario
    $this->usuario = $this->post('usuario');
    /**
    * NOTA: para que la autocarga aplique de forma correcta, es necesario que llame a la variable de instancia
    * igual como esta el model de la vista, en este caso el model es "menus" y quedaria $this->menus
    */
    }else{
    Flash::success('Operación exitosa');
    }}else {
    Flash::error('Usuario ya existe/intente ingresando otro Usuario');
    $this->usuario = $this->post('usuario');
    }
    }
    }
Sign In or Register to comment.