0

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 enter image description here

Mik
  • 1,705
  • 1
  • 14
  • 26
  • What is the reason of you need to show hidden field as normal input field? Why just use normal input field? – Egor Smirnov Dec 13 '12 at 13:29
  • i need a fileupload field which still shows the input field which belongs to it.. normally with other frameworks i had problems to hide this field in other designs but in this version they want to see both.. the uploadFile button and the input – Mik Dec 13 '12 at 13:31
  • 1
    Am I correct in understanding you want to show both an input for the file path, and a button to select the file? That's the default behavior - the hidden field generated by `activeFieldField` is so that other code can `use isset($_POST[$modelClass]) to detect if the input is submitted` ([source](https://github.com/yiisoft/yii/blob/1.1.12/framework/web/helpers/CHtml.php#L1386)) – ernie Dec 13 '12 at 18:15

1 Answers1

1

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();​
Community
  • 1
  • 1
Stu
  • 4,160
  • 24
  • 43