Yii Framework Forum: [EXTENSION] Ajax CRUD gii Template - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] Ajax CRUD gii Template Rate Topic: -----

#21 User is offline   marios 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 21-September 12
  • Location:Kavala, Greece

Posted 02 October 2012 - 09:09 AM

View Posticeinrain, on 05 July 2012 - 09:23 AM, said:

that line should be 'afterValidate'=>'$.js_afterValidate',
just a little dot can mess whole control




God bless you my friend...i was trying for days to find what the problem was!!

Thank you again!!
0

#22 User is offline   marios 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 21-September 12
  • Location:Kavala, Greece

Posted 09 October 2012 - 08:26 AM

Hello guys!!

I'll get into the point directly. I have an image field on a database's table where i want to store an image. While googling around i figured out that the best way to do that is to store the image on the server's file system and keep the internal path of the image to the appropriate field.

So i've added to the _ajax_form.php the following lines of code:

<div class="row">        
<?php echo $form->labelEx($model,'Infrastructure_Photo'); ?>        
<?php echo CHtml::activeFileField($model, 'Infrastructure_Photo');         
<span id="success-Infrastructures_Infrastructure_Photo" class="hid input-notification-success  success png_bg right"></span>        
<div>  
<small></small>        
</div>        
 <?php echo $form->error($model,'Infrastructure_Photo'); ?>     
</div>


and in the controller and particularly in the actionAjax_Create() method the following:

$uploadedFile=CUploadedFile::getInstance($model,'Infrastructure_Photo');  
$fileName = "{$model->id}"; // I want to change the image's filename to something more meaningful to me like (so as not to have overwriting images) that is the record id.
$model->Infrastructure_Photo = $fileName; 
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/'.$fileName);



The problem is that when using the $fileName = "{$model->id}"; or the $fileName = "{$this->id}"; can't make it work properly. In fact nothing is saved unless i change the command to $fileName = "whateveriwant"; Obviously the file is saved named as whateveriwant.jpg but that's for once.

The point is that i want to rename the image every time so it fits with the record id of a particular record.

Has anybody tried to do something similar to this??
0

#23 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 831
  • Joined: 20-April 11
  • Location:India

Posted 10 October 2013 - 12:51 AM

Custom Validation rules and validation like 'unique'are not working . What to do?
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users