예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Departamento::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['codigo' => $this->codigo]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
예제 #2
0
파일: _form.php 프로젝트: RodmanII/sgm
?>
      </span>
    </div>

    <?php 
echo $form->field($model, 'direccion')->textInput(['readonly' => true, 'maxlength' => true]);
?>

    <div class="cflex">
      <span style="order: 1; flex-grow: 1; margin-right:10px;">
        <div class="form-group">
          <?php 
echo Html::label('Departamento de Origen', 'deptomo');
?>
          <?php 
echo Html::dropDownList('departamento', null, ArrayHelper::map(Departamento::find()->all(), 'codigo', 'nombre'), ['id' => 'deptomo', 'class' => 'form-control', 'onchange' => '
          $.post( "' . Yii::$app->urlManager->createUrl('general/municipios?id=') . '"+$(this).val(), function( data ) {
            $("select#munico").html(data);
            $("#munico").val(' . $model->cod_mun_origen . ');
          });
          ']);
?>
        </div>
      </span>
      <span style="order: 2; flex-grow: 1; margin-right:10px;">
        <?php 
if (!$model->isNewRecord) {
    $objMunicipio = Municipio::find()->where('codigo = :valor', [':valor' => $model->cod_mun_origen])->one();
    $this->registerJs('$("#deptomo").val(' . $objMunicipio->codDepartamento->codigo . ').change();', View::POS_READY);
}
?>