@@ -160,10 +160,10 @@ |
||
160 | 160 | $this->address->country = $this->country->getIsoAlpha2(); |
161 | 161 | } |
162 | 162 | if(!empty($this->defaultCountry)) { |
163 | - if(!in_array($this->defaultCountry, $this->allowedCountries)) { |
|
164 | - throw new ErrorException("the set defaultCounty '{$this->defaultCountry}' must be one of the configured allowedCountries"); |
|
165 | - } |
|
166 | - $this->country = country($this->defaultCountry); |
|
163 | + if(!in_array($this->defaultCountry, $this->allowedCountries)) { |
|
164 | + throw new ErrorException("the set defaultCounty '{$this->defaultCountry}' must be one of the configured allowedCountries"); |
|
165 | + } |
|
166 | + $this->country = country($this->defaultCountry); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | if (empty($this->submitText)) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $countryList = []; |
112 | 112 | foreach ($this->countries as $country) { |
113 | - $countryList[$country->getIsoAlpha2()] = $country->getEmoji(). " " . $country->getName(); |
|
113 | + $countryList[$country->getIsoAlpha2()] = $country->getEmoji() . " " . $country->getName(); |
|
114 | 114 | } |
115 | 115 | return $countryList; |
116 | 116 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $params = []; |
151 | 151 | if (!empty($this->disabledFields)) { |
152 | 152 | $requiredFields = array_diff(Address::$defaultRequiredFields, $this->disabledFields); |
153 | - $params['requiredFields'] = $requiredFields; |
|
153 | + $params['requiredFields'] = $requiredFields; |
|
154 | 154 | } |
155 | 155 | $this->address = new Address($params); |
156 | 156 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | $this->country = country($this->allowedCountries[0]); |
160 | 160 | $this->address->country = $this->country->getIsoAlpha2(); |
161 | 161 | } |
162 | - if(!empty($this->defaultCountry)) { |
|
163 | - if(!in_array($this->defaultCountry, $this->allowedCountries)) { |
|
162 | + if (!empty($this->defaultCountry)) { |
|
163 | + if (!in_array($this->defaultCountry, $this->allowedCountries)) { |
|
164 | 164 | throw new ErrorException("the set defaultCounty '{$this->defaultCountry}' must be one of the configured allowedCountries"); |
165 | 165 | } |
166 | 166 | $this->country = country($this->defaultCountry); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use tonisormisson\addressform\AddressHelper; |
10 | 10 | use yii\helpers\ArrayHelper; |
11 | 11 | |
12 | -$country =$widget->getCountry(); |
|
12 | +$country = $widget->getCountry(); |
|
13 | 13 | $countryDisabled = count($widget->allowedCountries) < 2; |
14 | 14 | ?> |
15 | 15 | |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | 'pluginOptions'=>[ |
28 | 28 | 'placeholder' => $widget->placeHolders['country'], |
29 | 29 | ], |
30 | - ]);?> |
|
31 | - <?= $countryDisabled ? $form->field($model, 'country')->hiddenInput(['value'=> $country->getIsoAlpha2()])->label(false) : null ?> |
|
30 | + ]); ?> |
|
31 | + <?= $countryDisabled ? $form->field($model, 'country')->hiddenInput(['value'=> $country->getIsoAlpha2()])->label(false) : null ?> |
|
32 | 32 | </div> |
33 | 33 | |
34 | 34 | <div class="col-sm-6"> |
35 | - <?php if(is_null($country)):?> |
|
35 | + <?php if (is_null($country)):?> |
|
36 | 36 | <?= $form->field($model, 'state')->widget(DepDrop::class, [ |
37 | 37 | 'type'=>DepDrop::TYPE_SELECT2, |
38 | 38 | 'select2Options'=>['pluginOptions'=>['allowClear'=>true]], |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | 'loadingText' => Yii::t("addressform", "Loading") . "...", |
44 | 44 | 'value' => !is_null($country) ? (new AddressHelper())->formatList($country->getDivisions()) : [], |
45 | 45 | ], |
46 | - ]);?> |
|
46 | + ]); ?> |
|
47 | 47 | <?php else:?> |
48 | 48 | <?= $form->field($model, 'state')->widget(Select2::class, [ |
49 | - 'data'=> ArrayHelper::map((new AddressHelper())->formatList($country->getDivisions()),'id', 'name'), |
|
49 | + 'data'=> ArrayHelper::map((new AddressHelper())->formatList($country->getDivisions()), 'id', 'name'), |
|
50 | 50 | 'options' => [ |
51 | 51 | 'placeholder' => $widget->placeHolders['state'], |
52 | 52 | ], |
53 | - ]);?> |
|
54 | - <?php endif;?> |
|
53 | + ]); ?> |
|
54 | + <?php endif; ?> |
|
55 | 55 | </div> |
56 | 56 | </div> |