</p> <div id="statusMsg"> <?php if (Yii::app()->user->hasFlash('success')) { ?> <div class="alert alert-block alert-success"> <?php echo Yii::app()->user->getFlash('success'); ?> </div> <?php } ?> <?php if (Yii::app()->user->hasFlash('error')) { ?> <div class="alert alert-block alert-error"> <?php echo Yii::app()->user->getFlash('error'); ?> </div> <?php } ?> </div> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'material-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('description', array('name' => 'cat_id', 'value' => '$data->cat->description', 'filter' => MaterialCategory::model()->getCategories(), 'htmlOptions' => array('width' => '150px')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'afterDelete' => 'function(link,success,data){ if(success) $("#statusMsg").html(data); }'))));
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'poitems-form', 'enableClientValidation' => true)); ?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->hiddenField($model, 'po_number'); ?> <?php echo $form->dropDownListRow($model, 'material_cat', MaterialCategory::model()->getCategories(), array('prompt' => 'Select Category', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('material/dynamicmaterial'), 'update' => '#PoItems_material_id', 'data' => array('material_cat' => 'js:this.value')))); ?> <?php echo $form->dropDownListRow($model, 'material_id', array(), array('prompt' => 'Select Category')); ?> <?php echo $form->textFieldRow($model, 'qty', array('class' => 'span5', 'maxlength' => 12)); ?> <?php echo $form->textFieldRow($model, 'qty_units', array('class' => 'span5', 'maxlength' => 15)); ?> <?php
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'material-form', 'enableAjaxValidation' => false)); ?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->dropDownListRow($model, 'cat_id', MaterialCategory::model()->getCategories()); ?> <?php echo $form->textFieldRow($model, 'description', array('class' => 'span5', 'maxlength' => 150)); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Create' : 'Save')); ?> </div> <?php $this->endWidget();
public function getCategories() { return CHtml::listData(MaterialCategory::model()->findAll(), 'cat_id', 'description'); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = MaterialCategory::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }