/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $modelSensor = new Sensor(); $modelSensor->setScenario('buscar'); $model = null; $idSensor = null; if (isset($_POST['Sensor'])) { $modelSensor->attributes = $_POST['Sensor']; if ($modelSensor->validate()) { $model = Sensor::model()->getSensorValores($modelSensor->idsensor); $idSensor = $modelSensor->idsensor; } } $this->render('index', array('model' => $model, 'modelSensor' => $modelSensor, 'idSensor' => $idSensor)); }
static function getListSensor() { $models = Sensor::model()->findAll(array('order' => 'idsensor')); $list = CHtml::listData($models, 'idsensor', 'descripcion'); return $list; }
<div class="row"> <div class="col-lg-12"> <h3>Visualizador de sensores</h3> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'certificado-form', 'enableAjaxValidation' => false)); ?> <?php //echo $form->errorSummary($modelSensor); ?> <div class="input-group"> <?php echo $form->dropDownList($modelSensor, 'idsensor', Sensor::model()->getListSensor(), array('empty' => 'seleccione sensor', 'class' => 'form-control', 'options' => array($idSensor => array('selected' => 'selected')))); ?> <span class="input-group-btn"> <?php echo CHtml::submitButton('Seleccionar', array('class' => 'btn btn-default')); ?> </span> </div> <div class="form-group"> <?php echo $form->error($modelSensor, 'idsensor', array('class' => 'alert alert-danger')); ?> </div> <?php