Hi
I have a file upload that is required as part of a form. I have the following rules
However when I leave the file upload blank it still tries to process the form.
What am I doing wrong?
Thanks for any help
I have a file upload that is required as part of a form. I have the following rules
array('file', 'file', 'on' => 'insert', 'allowEmpty' => false, 'safe'=>true, 'maxSize'=> 512000, 'maxFiles'=> 1, 'mimeTypes' => 'application/msword, text/plain', 'tooLarge'=> 'file cannot be larger than 500KB.', 'wrongMimeType'=> 'Format must be: .doc .txt' ),
However when I leave the file upload blank it still tries to process the form.
<?php $form = $this->beginWidget('GxActiveForm', array( // Giix extension 'id' => 'file-form', 'enableAjaxValidation' => false, 'htmlOptions'=> array('enctype'=> 'multipart/form-data'), )); ?> <div class="row"> <?php echo $form->labelEx($model,'name'); ?> <?php echo $form->textField($model, 'name', array('maxlength' => 80)); ?> <?php echo $form->error($model,'name'); ?> </div><!-- row --> <div class="row"> <?php echo $form->fileField($model, 'file'); ?> <?php echo $form->error($model,'file'); ?> </div><!-- row -->
What am I doing wrong?
Thanks for any help