<?php $form = $this->beginWidget('CActiveForm', array('id' => 'book-type-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'parent_id'); ?> <?php echo $form->dropDownList($model, 'parent_id', BookType::model()->getAllTypes()); ?> <?php echo $form->error($model, 'parent_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'title'); ?> <?php echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'title');
/** * 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. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = BookType::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
echo $form->labelEx($model, 'author'); ?> <?php echo $form->textField($model, 'author', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'author'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'book_type'); ?> <?php echo $form->dropDownList($model, 'book_type', BookType::model()->getAllTypes()); ?> <?php echo $form->error($model, 'book_type'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'release_date'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'release_date', 'model' => $model, 'attribute' => 'release_date', 'language' => 'ru', 'options' => array('showAnim' => 'fold'), 'htmlOptions' => array('style' => 'height:20px;'))); ?> <?php echo $form->error($model, 'release_date');
<?php $this->breadcrumbs = array('Books' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List Book', 'url' => array('index')), array('label' => 'Create Book', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('book-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Книги</h1> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'book-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('class' => 'EImageColumn', 'imagePathExpression' => 'Yii::app()->baseUrl."/images/books/".$data->id.$data->image', 'emptyText' => '—', 'imageOptions' => array('height' => 100)), 'title', 'author', array('name' => 'book_type', 'filter' => BookType::model()->getAllTypes(), 'value' => function ($data) { return $data->category->title; }), 'release_date', array('class' => 'CButtonColumn'))));