Commits

Anonymous committed 085f2d5

Added file field generation (for image-like field names). Need to fix: 1) 2+ image (upload) fields generation; 2) valid attribute label generation using array-notation (e. g. "photo[]", for html5 multiupload possibility).

Comments (0)

Files changed (1)

generators/AweCrud/AweCrudCode.php

             return "\$form->dropDownListRow(\$model, '{$column->name}', CHtml::listData({$relatedModelClass}::model()->findAll(), '{$foreignPk}', {$relatedModelClass}::representingColumn()){$prompt})";
         }
 
-        if (strtoupper($column->dbType) == 'TINYINT(1)'
+        if($column->name == $this->hasUpload()) {
+            return "\$form->fileFieldRow(\$model, '{$column->name}[]', array('multiple' => 'multiple'))";
+        } elseif (strtoupper($column->dbType) == 'TINYINT(1)'
             || strtoupper($column->dbType) == 'BIT'
             || strtoupper($column->dbType) == 'BOOL'
             || strtoupper($column->dbType) == 'BOOLEAN'
         return $controller;
     }
 
+    public function hasUpload()
+    {
+        foreach($this->tableSchema->columns as $column)
+        {
+            if (in_array($column->name, $this->imageFields))
+            {
+                return $column->name;
+                break;
+            }
+        }
+
+        return false;
+    }
 }