<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'menu-form', 'enableAjaxValidation' => false, 'type' => 'horizontal')); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->hiddenField($model, 'business_id'); ?> <?php echo $form->dropDownListRow($model, 'category', CHtml::listData(MenuCategory::model()->findAll(), 'id', 'name'), array('empty' => 'Select a type')); ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'size' => 60, 'maxlength' => 100)); ?> <?php echo $form->textAreaRow($model, 'description', array('class' => 'span6', 'rows' => 5)); ?> <?php echo $form->textFieldRow($model, 'price', array('class' => 'span2', 'prepend' => '$', 'maxlength' => 6)); ?> <div class="row buttons"> <?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
/** * 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 = MenuCategory::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * @return string the category text display for the current menu */ public function getCategoryText() { $categoryOptions = CHtml::listData(MenuCategory::model()->findAll(), 'id', 'name'); return isset($categoryOptions[$this->category]) ? $categoryOptions[$this->category] : "-"; }