Question: I am trying to put [MaxMind's GeoIp2](https://github.com/maxmind/GeoIP2-php/tree/master/src/GeoIp2) into my Yii application. Basically, I copied the files under "src" (see previous link) under `protected -> vendors -> maxmind`. The folder structure under my application is the following:

```
protected
|---- vendors
      |---- Zend
      |---- maxmind
           |---- Database
                 |---- Reader.php
           |---- Model
           |---- ...
      |---- ...

```

After that, I created the path aliases into my index.php file:

```
Yii::setPathOfAlias('Zend', Yii::getPathOfAlias('application.vendors.Zend'));
Yii::setPathOfAlias('GeoIp2',   Yii::getPathOfAlias('application.vendors.maxmind'));

```

The path works just fine for the 'Zend' alias, but it fails for 'GeoIp2' by returning `null`.

```
Yii::createApplication("FrontendApplication", $config)->run();
echo "Path 1: " . Yii::getPathOfAlias("Zend"). '<br />'; // Correct path!
echo "Path 2: " . Yii::getPathOfAlias("GeoIp2"). '<br />'; // <==== NULL
echo "Maxmind path: " . Yii::getPathOfAlias('application.vendors.maxmind'). '<br />'; // correct path

var_dump(is_dir(Yii::getPathOfAlias('application.vendors.maxmind'))); // true

```

Any ideas why this could happen?

Thanks!

Answer: 
You can't put a form in a button, the button must be in the form. You need to write the returned value where you can see it.

```
<form>
  <button type="button" onclick="this.form.timeField.value=getTimeStamp()">Get time stamp</button>
  <input type="text" name="timeField" size="11">
</form>

```

Don't give any element in the document a name or ID that is the same as a global variable (e.g. a form and function called "getTimeStamp").

Remove:

```
window.onclick = "getTimeStamp";

```

it assigns the string "getTimeStamp" to the *onclick* property of *window*, and does nothing useful.

You can also remove:

```
language="JavaScript" type="text/javascript"

```

The first was only necessary in very particular circumstances a long time ago, the second was never really necessary other than being required in HTML 4. It's not required any longer. :-)
In your code you have some basic errors.

This is working example:

```
<html>
<head>
<script type="text/javascript">
function getTimeStamp() {
       var now = new Date();
       return ((now.getMonth() + 1) + '/' + (now.getDate()) + '/' + now.getFullYear() + " " + now.getHours() + ':'
                     + ((now.getMinutes() < 10) ? ("0" + now.getMinutes()) : (now.getMinutes())) + ':' + ((now.getSeconds() < 10) ? ("0" + now
                     .getSeconds()) : (now.getSeconds())));
}
function setTime() {
    document.getElementById('field').value = getTimeStamp();
}
</script>

</head>

<body onload="setTime()">

<input id="field" type="text" name="field" value="" size="11" />
<button type="button" onclick="setTime();">Get Time</button>

</body>
</html>

```

1. you cannot nest `form` under `button`; in this case you can skip the `form`
2. you need somehow identify the `input` which you want to set the time
3. you can reach this `input` by setting it the ID
4. in my example I am using `onload` event in `body` element to set the initial timestamp

If you have any questions you can ask them.