简体   繁体   中英

Yii how to show hidden input field of fileUpload generated with $form->formField()

I want to show the hidden input field which is generated with the CActiveForm->fileField()

<?php $form=$this->beginWidget('CActiveForm', array(
                'id'=>'user-_profile-form',
                'enableAjaxValidation'=>false,
                'htmlOptions'=>array(
                    'enctype'=>'multipart/form-data'
                )
            )); ?>
// some code here

<?php echo $form->labelEx($model,'file_upload'); ?>

<?php echo $form->fileField($model,'file_upload'); ?>

// some code here

<?php $this->endWidget(); ?>

the output looks like this

<label for="User_file_upload">File Upload</label>

<input id="ytUser_file_upload" type="hidden" value="" name="User[file_upload]">
<input name="User[file_upload]" id="User_file_upload" type="file">

and i want that the hidden field shows as a normal input field.. because the design is asking for that

would be nice if anybody has a suggestion for me

thanks in advance

EDIT:

here an image of what i need 在此处输入图片说明

You could do this client side with javascript?

Looking at this SO post: jQuery: Change element type from hidden to input you could modify it for your form ( jsfiddle ):

marker = $('<span />').insertBefore('#ytUser_file_upload');
$('#ytUser_file_upload').detach().attr('type', 'text').insertAfter(marker).focus();
marker.remove();​

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM