<p class="note">Los campos con <span class="required">*</span> son requeridos.</p> <?php echo $form->errorSummary($model); ?> <?php Yii::app()->clientScript->registerScript('spartsPartsScript', "\n\t\t\t\$('#addSparePart').click(function(){\n\t\t\t\tif (\$('#spare_parts_id option:selected').val()) {\n\t\t\t\t\t\$('#SparePartsOrder_spareParts').append(\n\t\t\t\t\t\t\$('#spare_parts_id option:selected').remove()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\n\t\t\t\$('#removeSparePart').click(function(){\n\t\t\t\t\$('#SparePartsOrder_spareParts option:selected').remove();\n\t\t\t});\n\t\t\n\n\t\t\t\$('#spare-parts-order-form').submit(function(){\n\t\t\t\t\$('#SparePartsOrder_spareParts option').attr('selected','selected');\n\t\t\t});\n\t\t"); ?> <div class="row"> <?php echo $form->labelEx($model, 'spare_parts_type_id'); ?> <?php echo $form->dropDownList($model, 'spare_parts_type_id', CHtml::listData(SparePartsType::model()->findAll(array('condition' => 'active =1', 'order' => 'type')), 'id', 'type'), array('prompt' => 'Seleccionar', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('sparePartsOrder/sparePartsFromType'), 'data' => array('SparePartsOrder[spare_parts_type_id]' => 'js:this.value'), 'update' => '#spare_parts_id'))); ?> <?php echo $form->error($model, 'spare_parts_type_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'spare_parts_id'); ?> <?php //echo $form->dropDownList( echo CHtml::dropDownList('spare_parts_id', null, CHtml::listData(SpareParts::model()->findAll(array('condition' => 'active =1 AND spare_parts_type_id = :spare_parts_type_id', 'order' => 'name', 'params' => array(':spare_parts_type_id' => $model->spare_parts_type_id))), 'id', 'name'), array('prompt' => 'Seleccionar'));
?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'spare-parts-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => true))); ?> <p class="note">Los campos con <span class="required">*</span> son requeridos.</p> <div class="row"> <?php echo $form->labelEx($model, 'spare_parts_type_id'); ?> <?php echo $form->dropDownList($model, 'spare_parts_type_id', CHtml::listData(SparePartsType::model()->findAll(array('condition' => 'active = 1', 'order' => 'type')), 'id', 'type'), array('empty' => 'Seleccionar Tipo')); ?> <?php echo $form->error($model, 'spare_parts_type_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'brand_id'); ?> <?php echo $form->dropDownList($model, 'brand_id', CHtml::listData(Brand::model()->findAll(array('condition' => 'active = 1', 'order' => 'name')), 'id', 'name'), array('empty' => 'Seleccionar Marca')); ?> <?php echo $form->error($model, 'brand_id');
public function getTypes() { return $ModelTypes = SparePartsType::model()->findAll('active = 1'); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return SparePartsType the loaded model * @throws CHttpException */ public function loadModel($id) { $model = SparePartsType::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }