Closed aidonsnous closed 8 years ago
Here is the solution;
This :
public function behaviors(){ return [ [ "class" => "sjaakp\illustrated\Illustrated", "attributes"=>[ 'img'=>[ 'aspectRatio'=>1.0, 'cropSize'=>90,] ] ], ]; }
Should be:
public function behaviors(){ return [ [ "class" => "sjaakp\illustrated\Illustrated", "attributes"=>[ 'photo'//Important to put the attribute of fileinput, 'img'=>[ 'aspectRatio'=>1.0, 'cropSize'=>90,] ] ], ]; }
In fact you created a model with two Illustrations: one called ‘photo’, having the default options (aspectRatio = 1.0, cropSize =240), and the other called ‘img’ with aspectRatio = 1.0 and cropSize = 90.
Please, first try the simplest case, one illustration without any options:
class NicePlace extends ActiveRecord {
public function behaviors() {
return [
‘class’ => ‘sjaakp\illustrated\Illustrated’,
‘attributes’ => [
‘photo’
]
];
}
}
In the view:
use sjaakp\illustrated\Uploader;
...
<?= $form->field($model, 'photo')->widget(Uploader::className()) ?>
...
That’s really all.
Sjaak Priester
mailto:sjaak@sjaakpriester.nl sjaak@sjaakpriester.nl
From: MagSag [mailto:notifications@github.com] Sent: Friday, December 4, 2015 9:56 AM To: sjaakp/yii2-illustrated-behavior yii2-illustrated-behavior@noreply.github.com Subject: Re: [yii2-illustrated-behavior] I am getting error; Is there any complete example of how to use the behavior(configuration in model,view,controller) practically (#15)
Here is the solution;
This :
public function behaviors(){ return [ [ "class" => "sjaakp\illustrated\Illustrated", "attributes"=>[ 'img'=>[ 'aspectRatio'=>1.0, 'cropSize'=>90,] ] ], ]; }
Should be:
public function behaviors(){ return [ [ "class" => "sjaakp\illustrated\Illustrated", "attributes"=>[ 'photo'//Important to put the attribute of fileinput, 'img'=>[ 'aspectRatio'=>1.0, 'cropSize'=>90,] ] ], ]; }
— Reply to this email directly or view it on GitHub https://github.com/sjaakp/yii2-illustrated-behavior/issues/15#issuecomment-161911550 . https://github.com/notifications/beacon/AFU71uj1aX7VEd9XE50kNLr8W84w75Idks5pMUyXgaJpZM4Gs4VU.gif
Thanks dear but I've solved that problem my preoccupations are the issue 16 and 14 for now.
Is there any complete example of how to use the behavior(configuration in model,view,controller) and what are requirements to use the extension(which libraries are need). I am confused I don't know what to do things that I am trying are not working: In my model:
public $photo;//The file attributes public function behaviors(){ return [ [ "class" => "sjaakp\illustrated\Illustrated", "attributes"=>[ 'img'=>[ 'aspectRatio'=>1.0, 'cropSize'=>90,] ] ], ]; } //rules : $rules[] = ['photo','file'];
In my view use sjaakp\illustrated\Uploader;
<?= $form->field($model, 'photo')->widget(Uploader::className([ 'deleteOptions' => [ 'label' => '', // Font Awesome icon 'title' => 'Delete image' ] ])) ?>
= Html::submitButton(Yii::t('app', 'Exit'), ['class' => 'btn btn-danger cancel btn-block']) ?>
With that I am getting errror : Undefined index: photo