我的问题是我的功能并没有改变我的列表框,奇怪的是,它在工作前几天却已经不存在了。
在我看来,我有这个:
<script>
function show_alert()
{
if (confirm("¿Esta seguro de guardar el formulario?")) { return true; }
return false;
}
</script>
<?php
echo $this->Html->css(array('buttons'));
echo $this->Html->script('alertify');
echo $this->Html->css(array('alertify.core', 'alertify.default'));
ini_set('memory_limit', '-1');
?>
<div class="actions">
<ul>
<li><?php echo $this->Html->link( "Volver Atrás", array('action'=>'index') ); ?></li>
</ul>
</div>
<table style="weight: 100%">
<div id="contenedorr10" style="right:20px; float: right;">
<h3 align="right"><?php echo $this->Time->format('F jS, Y', time());?></h3>
<h3 align="right" style="font-size:14px">
<?php
if($this->Session->check('Auth.User')){
echo $this->Html->link( "Cerrar Sesión", array('action'=>'logout') , array('class' => 'large green awesome'));
}else{
echo $this->Html->link( "Regresar al login de usuarios", array('action'=>'login'), array('class' => 'large green awesome'));
}
?>
</h3>
</div>
</table>
<div class="cambiodolar form">
<h3 align="center"><strong align="center">AGREGAR ASOCIACIONES</strong></h3>
<table align="left" width="50px">
<tr>
<td width="20px">
<h3 align="right" style="font-size:18px"><strong align="center">FUNCIÓN:</strong></h3>
</td>
<td>
<h3 align="left" style="font-size:18px">Panel de Registro</h3>
</td>
</tr>
<tr>
<td width="20px">
<h3 align="right" style="font-size:18px"><strong align="center">ACCIÓN:</strong></h3>
</td>
<td>
<h3 align="left" style="font-size:18px">Registro de Asociaciones</h3>
</td>
</tr>
<tr>
<td width="20px">
<h3 align="right" style="font-size:18px"><strong align="center">SUJETO:</strong></h3>
</td>
<td>
<h3 align="left" style="font-size:18px">Asociaciones</h3>
</td>
</tr>
</table>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<?php echo $this->Form->create('SoyaAsociaciones');?>
<fieldset>
<?php
echo $this->Form->input('nombre', array('label' => 'Ingrese Nombre de la Asociación','style'=>'width:500px; height:30px;'));
echo $this->Form->input('soya_rubro_id',
array('options' => $rubros,
'id' => 'PostRubroId',
'empty' => '--Porfavor selecione--',
'label' => 'Seleccione rubro')
);
echo $this->Form->input('soya_subrubro_id',
array( 'id' => 'PostSubrubroId',
'empty' => '--Porfavor selecione--',
'label' => 'Seleccione subrubro' )
);
echo $this->Form->input('ciudad_id', array( 'options' => $ciudades,'empty' => '--Por favor seleccione--','label' => 'Seleccione Ciudad' ));
echo $this->Form->submit('Agregar Asociación', array('class' => 'form-submit', 'title' => 'Presione aqui para agregar datos', 'onclick' => 'return show_alert();'));
$this->Js->get('#PostRubroId')->event('change',
$this->Js->request(array(
'controller'=>'soyasubrubros',
'action'=>'getByRubro'
), array(
'update'=>'#PostSubrubroId',
'async' => true,
'method' => 'post',
'dataExpression'=>true,
'data'=> $this->Js->serializeForm(array(
'isForm' => true,
'inline' => true
))
))
);
?>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>
<div class="actions">
<h3>Acciones</h3>
</div>
在我的控制器里我有这个:
public function getByRubro() {
$this->loadModel('SoyaSubrubro');
$soya_rubro_id = $this->request->data['SoyaAsociaciones']['soya_rubro_id'];
debug($soya_rubro_id);
$subcategories = $this->SoyaSubrubro->find('list', array(
'conditions' => array('SoyaSubrubro.soya_rubro_id' => $soya_rubro_id),
'fields'=>'subrubro',
'recursive' => -1
));
debug($this->set('subcategories',$subcategories));
$this->set('subcategories',$subcategories);
$this->layout = 'ajax';
}
在我的getByRubro视图中我有这个:
<?php
if(!empty($subcategories)){
foreach ($subcategories as $key => $value):
?>
<option value="<?php echo $key; ?>"><?php echo $value; ?></option>
<?php
endforeach;
} else {
?>
<option value="">No Data</option>
<?php
}
?>
当我改变&#34; soya_rubro_id&#34;列表框,我改变了选项,我没有加载我的模型&#34; SubRubros&#34;我不知道为什么,请提前帮助,谢谢......