hola Ogalav, si lo vi no se si en este grupo o en el otro de cakephp y
bueno te pongo el codigo de lo ke vi he hice.
en mi controller
class AlumnosController extends AppController {
var $name = 'Alumnos';
var $names = 'Idiomas';
//var $nmes = 'Niveles';
var $nams = 'Maestros';
var $helpers = array('Html', 'Form',);
function validacion() {
if (empty($this->data)){
$this->set('alumnos', null);
}
else{
if ($this->Alumno->save($this->data)){
$this->Session->setFlash('Has quedado registrado');
$this->redirect(array('action'=>'registro'), null, true);
$this->Session->setFlash('No has quedado registrado. Prueba
de nuevo');
}
else{
$data = $this->data;
$this->set('alumnos', $data);
}
}
$this->set('idiomas', $this->Alumno->Idioma->find('list'));
//$this->set('niveles', $this->Alumno->Nivel->find('list'));
$this->set('maestros', $this->Alumno->Maestro->find('list'));
}
}
?>
en mi model
<?php
class Alumno extends AppModel {
var $name = 'Alumno';
var $validate= array(
'exp_alumno'=>array('numeric'),
'nombre_alu'=>array('rule'=>'notEmpty'),
'facultad'=>array('rule'=>'notEmpty'),
'id_idioma'=>array('rule'=>'notEmpty'),
/*'id_nivel'=>array('rule'=>'notEmpty'),*/
'id_maestro'=>array('rule'=>'notEmpty'),
);
var $belongsTo = array(
'Idioma' => array(
'className'=>'Idioma',
'foreignKey'=>'id'),
/*'Nivel' => array(
'className'=>'Nivel',
'foreignKey'=>'id'),*/
'Maestro' => array(
'className'=>'Maestro',
'foreignKey'=>'id'),
);
}
?>
en mi view
<?php echo $this->Form->create('Alumno'); ?>
<fieldset>
<legend>Registro de alumno</legend>
<?php
echo $this->Form->input('exp_alumno', array('label'=>'Expediente:'));
echo $this->Form->input('nombre_alu', array('label'=>'Nombre:'));
echo $this->Form->input('facultad', array('label'=>'Facultad:'));
echo $this->Form->input('Idioma', array('type'=>'select',
'empty'=>'Selecciona el Idioma', 'options'=>$idiomas));
//echo $this->Form->input('Nivel', array('type'=>'select',
'empty'=>'Selecciona el Nivel', 'options'=>$niveles));
echo $this->From->input('Maestro', array('type'=>'select',
'empty'=>'Selecciona al Maestro', 'options'=>$maestros));
echo $this->Form->end('Registrarte');
//echo $this->Html->link('Lista de alumnos', array('action'=>'registro'));
?>
</fieldset>
lo que esta en rojo aun esta en consideracion si kiero o no ponerlo solo ke
ahy un pero ke como llamo dos drop down pues en la view ya cuando lo pongo
en mi navegador no me sale lo del maestro y aun no encuentro como ke la
solucion y me sale el siguiente error Fatal error: Call to a member
function input() on a non-object in
/home/rocha/www/cake/app/View/Alumnos/validacion.ctp on line 10 ojala y me
puedas o puedan ayudar con esto ... gracias!!!
--
Has recibido este mensaje porque estás suscrito al grupo "CakePHP-es" de Grupos
de Google.
Para ver este debate en la Web, visita
https://groups.google.com/d/msg/cakephp-es/-/Tiaqz7YRLaEJ.
Para publicar una entrada en este grupo, envía un correo electrónico a
[email protected].
Para anular tu suscripción a este grupo, envía un correo electrónico a
[email protected]
Para tener acceso a más opciones, visita el grupo en
http://groups.google.com/group/cakephp-es?hl=es.