All pastes #2050912 Raw Edit

cakephp

public text v1 · immutable
#2050912 ·published 2011-04-26 16:09 UTC
rendered paste body
add.ctp
-------
<h2>Planilla de Registro de Servicios Comunitarios</h2>
<p>Los campos con asterisco son obligatorios</p>
<?php
	echo $this->Form->create('Comunite');
	echo $this->Form->input('nombres');
	echo $this->Form->input('apellidos');
	echo $this->Form->input('telefono');
	echo $this->Form->input('email1');
	echo $this->Form->end('Enviar');
?>

comunites_controller.php
-------------------------

<?php
class ComunitesController extends AppController{
	var $helpers = array('Html', 'Form');
	var $name = 'Comunites';
	function index(){
		$this->set('comunites',$this->Comunite->find('all'));
	}

	function view($id){
		$this->Comunite->id = $id;
		$this->set('comunites', $this->Comunite->read());
	}

	function add(){
		if(!empty($this->data)){
			if($this->Comunite->save($this->data)){
			   $this->Session->setFlash('El post ha sido agregado');
			   $this->redirect(array('action'=>'index'));
			}
		}
	}
	function delete($id){
		if($this->Comunite->delete($id)){
		$this->Session->setFlash('The post con id:'.$id.' ha sido eliminado');
		$this->redirect(array('action'=>'index'));
		}
	}
	function sent(){
		$this->Session->setFlash('El post ha sido agregado');
	}
		
}	
?>