Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

'allowempty' => False Not Working

$
0
0
Hi

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>&lt!-- row -->
		<div class="row">
        <?php echo $form->fileField($model, 'file'); ?>
   		<?php echo $form->error($model,'file'); ?>
		</div>&lt!-- row -->



What am I doing wrong?

Thanks for any help

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>