This module solve "country/state/city" problem. If you have similar problem like "group/user/account" or "project/task/activity" … and need a unique solution, here you have that solution =).
Be shure to have ‘urlFormat’=>‘path’ enabled in your config file
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
),
),
Usage
<?php $this->widget('MSensorarioDropdown.extensions.ESensorarioDropdown'); ?>
Install
Move in your /protected/modules folder. If not exists, create it. And now clone
the repository on your project:
$ git clone git@github.com:sensorario/MSensorarioDropdown
And add it into your module list
'modules' => array(
...
'MSensorarioDropdown',
...
),
Configure
To configure this module, you need to update this config file:
/protected/modules/MSensorarioDropdown/config/maing.php
here the content:
<?php
return array(
'Country' => array(
'id' => 'stati',
'name' => 'Stati',
'model' => 'Stato::getStati();',
),
'State' => array(
'id' => 'regioni',
'name' => 'Regioni',
'model' => 'Regione::getRegione($id);',
'message' => 'Questa regione non ha comuni',
),
'City' => array(
'id' => 'comuni',
'name' => 'Comuni',
'model' => 'Comune::getComune($id);',
'message' => 'Questa regione non ha comuni',
),
);
The widget use these vars generating this html. The most important thing to
change is model and message. Message will appear when there are no city
once selected a state. Or there are no *state once selected a country.
<div class="box">
<span id="' . $this->config['Country']['id'] . '"></span>
<span id="' . $this->config['State']['id'] . '"></span>
<span id="' . $this->config['City']['id'] . '"></span>
</div>
Resources