some help with this ?
-- just edit on second click
my code
controller
public function admin_editar($id = null)
{
if (!$id)
{
throw new MethodNotAllowedException("Datos Invalidos");
}
$post = $this->Post->findById($id);
if (!$post)
{
throw new MethodNotAllowedException("El post no se pudo encontrar");
}
if ($this->request->is('post', 'put'))
{
$this->Post->id=$id;
if ($this->Post->save($this->request->data))
{
$this->Session->setFlash('El Post ah sido actualizado con exito', 'default', array('class' => 'alert alert-success alert-dismissible', 'role' => 'alert'));
return $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash('El Post no pudo ser guardado', 'default', array('class' => 'alert alert-success alert-dismissible', 'role' => 'alert'));
}
if (!$this->request->data)
{
$this->request->data = $post;
}
$this->set('id',$id);
$categorias = $this->Post->Categoria->find('list');
$this->set('categorias',$categorias);
$users = $this->Post->User->find('list');
$this->set('users',$users);
}
view
<section class="content">
<? echo $this->Form->create('Post'); ?>
<div class='row'>
<div class='col-md-12'>
<div class='box box-info'>
<div class='box-body pad'>
<?
//echo $this->Form->hidden('id',array('value'=>$id));
echo $this->Form->input('user_id', array('class' => 'form-control'));
echo "<br>";
echo $this->Form->input('categoria_id', array('class' => 'form-control'));
echo "<br>";
echo $this->Form->input('titulo', array('class' => 'form-control'));
echo "<br>";
echo $this->Form->textarea('post', array('class' => 'form-control'));
echo "<br>";
?>
</div>
</div><!-- /.box -->
</div><!-- ./row -->
<?
echo $this->Form->submit('Editar',array('class' => 'btn btn-primary'));
?>
</section><!-- /.content -->
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment