示例#1
0
<div style="margin-bottom: 20px; display: <?php 
echo !empty($display) ? $display : 'none';
?>
; width:100%; clear:left;" class="crow">
    <div class="row" style="width:300px;float: left;">
        <?php 
echo CHtml::activeLabelEx($model, '[' . $index . ']autor_name_id');
?>
        <?php 
//echo CHtml::activeTextField($model, '[' . $index . ']autor_name_id', array('size' => 20, 'maxlength' => 255));
?>
        <?php 
echo CHtml::activeDropDownList($model, '[' . $index . ']autor_name_id', Chtml::listData(Autorname::model()->findAll(array('order' => 'lastname, firstname')), 'id', 'fullname'), array('empty' => '--выберите автора--'));
?>
        <?php 
echo CHtml::error($model, '[' . $index . ']autor_name_id');
?>
    </div>
    <div class="row" style="width:100px;float: left;">
        <br />
        <?php 
echo CHtml::link('Delete', '#', array('onclick' => 'deleteAutor(this, ' . $index . '); return false;'));
?>
    </div>
</div>

<?php 
Yii::app()->clientScript->registerScript('deleteAutor', "\r\nfunction deleteAutor(elm, index)\r\n{\r\n    element=\$(elm).parent().parent();\r\n    /* animate div */\r\n    \$(element).animate(\r\n    {\r\n        opacity: 0.25,\r\n        left: '+=50',\r\n        height: 'toggle'\r\n    }, 500,\r\n    function() {\r\n        /* remove div */\r\n        \$(element).remove();\r\n    });\r\n}", CClientScript::POS_END);
 /**
  * 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 Autorname the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Autorname::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }