コード例 #1
0
ファイル: Stores.php プロジェクト: engmohamedamer/gotest
 public static function FetchDistrict($code)
 {
     if (\Yii::$app->language == "en") {
         $field = 'title';
     } else {
         $field = 'title_ar';
     }
     $cities = Govenment::find()->where('government_code=' . $code)->all();
     $listData = ArrayHelper::map($cities, 'district', 'district');
     return $listData;
 }
コード例 #2
0
 public function actionGovernment()
 {
     $code = $_REQUEST['code'];
     if (\Yii::$app->language == "en") {
         $field = 'title';
     } else {
         $field = 'title_ar';
     }
     $governments = Govenment::find()->where('country_code="' . $code . '"')->all();
     if (count($governments) > 0) {
         echo "<option value=''>" . Yii::t('easyii', 'City') . "</option>";
         foreach ($governments as $govern) {
             echo "<option value='" . $govern->government_code . "'>" . $govern->{$field} . "</option>";
         }
     } else {
         echo "<option>--</option>";
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: engmohamedamer/gotest
                        <?php 
echo $form->field($filterForm, 'country')->dropDownList(\app\models\Stores::FetchCountries(), ['prompt' => Yii::t('easyii', 'Country'), 'class' => 'btn btn-findUs dropdown-toggle', 'onchange' => '
                $.post( "' . Yii::$app->urlManager->createUrl('stores/government?code=') . '"+$(this).val(), function( data ) {
                  $( "select#gadgetsstoresfilterform-government" ).html( data );
                })'])->label('');
?>





                    </div>
                    <div class="col-md-4">
                        <?php 
if (isset($filterForm->country) and $filterForm->country != '') {
    $government = \app\models\Govenment::find()->where('country_code="' . $filterForm->country . '"')->all();
    $listData = \yii\helpers\ArrayHelper::map($government, 'government_code', 'title');
} else {
    $listData = [];
}
?>

                            <?php 
echo $form->field($filterForm, 'government')->dropDownList($listData, ['prompt' => Yii::t('easyii', 'Governorate'), 'class' => 'btn btn-findUs dropdown-toggle', 'onchange' => '
                $.post( "' . Yii::$app->urlManager->createUrl('stores/cities?code=') . '"+$(this).val(), function( data ) {
                  $( "select#gadgetsstoresfilterform-district" ).html( data );
                })'])->label('');
?>