Esempio n. 1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $contragents = Contragent::model()->findAll();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dogovor'])) {
         $model->attributes = $_POST['Dogovor'];
         if ($model->save()) {
             if (Yii::app()->request->isAjaxRequest) {
                 echo 'success';
                 Yii::app()->end();
             } else {
                 $this->actionAdmin();
             }
             //$this->redirect(array('view','id'=>$model->id));
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         // $this->renderPartial('dialog_view',array('dogovor_model'=>$model), false, true);
         // $this->renderPartial('_form',array('model'=>$model,'contragents'=>$contragents), false, true);
         $this->renderPartial('dialog_view', array('dogovor_model' => $model, 'contragents' => $contragents), false, true);
     } else {
         // $this->render('dialog_view',array('dogovor_model'=>$model));
         $this->renderPartial('dialog_view', array('dogovor_model' => $model, 'contragents' => $contragents), false, true);
     }
 }
 /**
  * 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 Contragent the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Contragent::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
<?php

$autocompleteConfig = array('model' => Contragent::model(), 'attribute' => 'name', 'htmlOptions' => array('class' => ''), 'source' => Yii::app()->createUrl('contragent/autocomplete'), 'options' => array('minLength' => '3', 'showAnim' => 'fold', 'select' => 'js: function(event, ui) {
// действие по умолчанию, значение текстового поля
// устанавливается в значение выбранного пункта
this.value = ui.item.label;
// устанавливаем значения скрытого поля
$("#User_id_firma").val(ui.item.id);
return false;
}'), 'htmlOptions' => array('maxlength' => 50, 'class' => 'form-control'));
?>




<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'user-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>

<div class="col-md-9">

    <div class="col-md-5">
        <div class="page-subtitle margin-bottom-0">
            <h3>Данные для авторизации</h3>

            <p>Важные поля для доступа к нашей системе</p>
        </div>
        <div class="form-group">
            <?php 
echo $form->error($model, 'username');
?>