}
```
We extend CInputWidget, the base widget for input field. This masterparent class gives use the attributes 'model' and 'attribute'.
AndNow, instead of the file field in our form we can place:
[...]
```
Excellent! Now we have a widget which works exactly how worked CHtml::activeFileField(), worked.
We can move forward forto use uploadify.
[...]
Following [uploadify's documentation](http://www.uploadify.com/documentation/ ""), we have to download the package and import it on the web page.
Let's save the package in protected/compomnents/assets for now.
Now we have to publish this directory and to include the files. All simple as:
```
The first instruction (assetsManger->publish) publishes the directory and returns the path created.
The other opinstructions publishes the script and css file. Please note that we are includeing the yii version of jquery (), not the uploadify one forto avoid conflicts.
### Register the script
Our objective is to register this script:e following js script, and to reserve us the possibility to customize it.
[...]
```
And to reserve us the possiblity of customize it.
Let's add a property options:
[...]
```
And then we prepare the options like thatis:
[...]
```
The options are made up by some default standard options (uploader, script ,cancelImg, folder and auto) that will be merged with the user defined options.
User defined options will take precedence (they are the second array in array_merge), so we will have the possibility of override the default ones.
This options will be encoded with Cjavascript::encode(), a magic function that allow to give javascript functions as parameters, we have just to write 'js:' at the beginning.
ForTo register the script we need only the id, we can generate the id with CHtml, respecting any chouice of the user:
```php
if (isset ($htmlOptions['id']))
$id= $htmlOptions['id'];
else
$id= CHtml::activeId($this->model, $this->attribute);
```
- Create a widget
- Download the library somewhere
- Publish the library
- Include needed script/css
- Prepare options and register the script
Here is the complete result:
[...]
For any customization, follow the documentation of uploadify. The work of Yii framework wais only to give a structure in which easyto inlclude all needed file.