tonisormisson / yii2-address-form
yii2-widget address-form
Installs: 2 686
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-module
Requires
- php: >=8.0.2
- kartik-v/yii2-widget-depdrop: ^1.0.4
- kartik-v/yii2-widget-select2: ^2.1.1
- rinvex/countries: ^8|^9
- yiisoft/yii2: >=2.0.14
Requires (Dev)
- phpstan/phpstan: ^1
README
A module doing address-form fields with dependent pre-set country-region drop-downs. Countries & regions powered by:
powered by rinvex/countries
250 countries & regions worldwide available
Example
add module config
the module part will take care of dep-drop ajax queries
'modules' => [
//...
'addressform' =>[
'class' => \tonisormisson\addressform\Module::class,
],
//...
]
place the widet
use tonisormisson\addressform\AddressForm;
echo AddressForm::widget([
'allowedCountries' => ["EE", "LV", "LT"],
'defaultCountry' => "EE",
'placeHolders' = [
// custom placeholders here if needed
'country' => ,
'state' => ,
'city' => ,
'postCode' => ,
'addressLine1' => ,
'addressLine2' => ,
],
]);
and catch the address in controller
use tonisormisson\addressform\models\Address;
$address = new Address();
$address->load(Yii::$app->request->post());
// load the address to your models
// eg :
$model->address_data = Json::encode($address);