Advertisement
Nass07

dept_form

Mar 24th, 2015
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3. use yii\helpers\Html;
  4. use yii\widgets\ActiveForm;
  5. use yii\helpers\ArrayHelper;
  6. use yii\helpers\Url;
  7.  
  8. /* @var $this yii\web\View */
  9. /* @var $model backend\modules\master\models\Department */
  10. /* @var $form yii\widgets\ActiveForm */
  11. ?>
  12.  
  13. <div class="department-form">
  14.  
  15.     <?php $form = ActiveForm::begin(); ?>
  16.  
  17.     <?= $form->field($model, 'departement')->textInput(['maxlength' => 150]) ?>
  18.  
  19.     <?php
  20.     $dataCompany=ArrayHelper::map(\backend\modules\master\models\Company::find()->asArray()->all(), 'id', 'company');
  21.     echo $form->field($model, 'id_company')->dropDownList($dataCompany,
  22.         ['prompt'=>'- Select Company -',
  23.             'onchange'=>'$.post("'.Yii::$app->urlManager->createUrl('master/factory/lists&id=').'"+$(this).val(),function( data )
  24.                   {$( "select#factory" ).html( data );});'
  25.         ]);
  26.     ?>
  27.  
  28.     <?php
  29.     $dataFactory=ArrayHelper::map(\backend\modules\master\models\Factory::find()->asArray()->all(), 'id', 'factory');
  30.     echo $form->field($model, 'id_factory')->dropDownList($dataFactory,
  31.         ['prompt'=>'- Select Factory -'])
  32.     ?>
  33.  
  34.     <?= $form->field($model, 'function')->textInput(['maxlength' => 250]) ?>
  35.  
  36.     <div class="form-group">
  37.         <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  38.     </div>
  39.  
  40.     <?php ActiveForm::end(); ?>
  41.  
  42. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement