9 public $params = array(
'path' =>
'assets');
21 'fieldType' => array(
'VARCHAR'),
22 'params' => $this->params,
23 'paramsLabels' => array(
26 'other_validator' => array(
28 'allowEmpty' => array(
'',
'false',
'true'),
51 $value = CUploadedFile::getInstance($model, $field_varname);
54 $old_file = $model->getAttribute($field_varname);
55 $file_name = $this->params[
'path'].
'/'.$value->name;
56 if (file_exists($file_name)) {
57 $file_name = str_replace(
'.'.$value->extensionName,
'-'.time().
'.'.$value->extensionName, $file_name);
59 if ($model->validate()) {
60 if ($old_file && file_exists($old_file)) {
63 $value->saveAs($file_name);
67 if (isset($_POST[get_class($model)][
'uwfdel'][$field_varname]) && $_POST[get_class($model)][
'uwfdel'][$field_varname]) {
68 $old_file = $model->getAttribute($field_varname);
69 if ($old_file && file_exists($old_file)) {
74 $value = $model->getAttribute($field_varname);
88 $file = $model->getAttribute($field->varname);
90 $file = Yii::app()->baseUrl.
'/'.$file;
92 return CHtml::link($file, $file);
105 if (!isset(
$params[
'options'])) {
111 return CHtml::activeFileField($model, $field->varname,
$params)
112 .(($model->getAttribute($field->varname)) ?
'<br/>'.CHtml::activeCheckBox($model,
'[uwfdel]'.$field->varname,
$params)
113 .
' '.CHtml::activeLabelEx($model,
'[uwfdel]'.$field->varname, array(
'label' =>
UserModule::t(
'Delete file'),
'style' =>
'display:inline;')) :
'')