当前位置: 首页>>代码示例>>PHP>>正文


PHP CHtml::activeFileField方法代码示例

本文整理汇总了PHP中CHtml::activeFileField方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::activeFileField方法的具体用法?PHP CHtml::activeFileField怎么用?PHP CHtml::activeFileField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHtml的用法示例。


在下文中一共展示了CHtml::activeFileField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fileField

 public function fileField($model, $attribute, $htmlOptions = array())
 {
     $controlOptions = BsArray::popValue('controlOptions', $htmlOptions, array());
     $labelOptions = BsArray::popValue('labelOptions', $htmlOptions, array());
     $layout = $this->layout;
     $output = '';
     $output .= CHtml::activeFileField($model, $attribute, $htmlOptions);
     $attr = $model->{$attribute};
     if (!empty($attr)) {
         //Special logic for ContentTypes
         $tmpModel = $model;
         if ($model instanceof ContentType) {
             $tmpModel = $model->Content;
         }
         $output .= '<p class="file">' . CHtml::link($model->{$attribute}, array('/site/getFile', 'id' => $tmpModel->id, 'field' => $attribute, 'modelName' => get_class($tmpModel))) . '</p>';
         $output .= '<div class="checkbox">' . CHtml::checkBox($attribute . '_delete');
         $output .= CHtml::label('Delete?', $attribute . '_delete') . '</div>';
     }
     $htmlOptions['input'] = $output;
     $htmlOptions['labelOptions'] = BsHtml::setLabelOptionsByLayout($layout, $labelOptions);
     if (!empty($layout)) {
         if ($layout === BsHtml::FORM_LAYOUT_HORIZONTAL) {
             $controlClass = BsArray::popValue('class', $controlOptions, BsHtml::$formLayoutHorizontalControlClass);
             BsHtml::addCssClass($controlClass, $htmlOptions['controlOptions']);
         }
     }
     return BsHTML::activeTextFieldControlGroup($model, $attribute, $htmlOptions);
 }
开发者ID:snapfrozen,项目名称:snapcms,代码行数:28,代码来源:SnapActiveForm.php

示例2: renderField

 /**
  * Renders the input file field
  */
 public function renderField()
 {
     if ($this->hasModel()) {
         echo \CHtml::activeFileField($this->model, $this->attribute, $this->options);
     } else {
         echo \CHtml::fileField($this->options['name'], $this->value, $this->options);
     }
 }
开发者ID:abudayah,项目名称:yiiwheels-custom,代码行数:11,代码来源:Fileupload.php

示例3: run

 /**
  * Generates the required HTML and Javascript
  */
 public function run()
 {
     //echo 'Chức năng upload file tạm thời Off để bảo trì, liên hệ trangptk@vega.com.vn';
     list($name, $id) = $this->resolveNameID();
     $model = $this->model;
     if (!isset($this->options['uploadTable'])) {
         $uploadTable = "files";
         $this->options['uploadTable'] = "#files";
     } else {
         $uploadTable = $this->options['uploadTable'];
         $this->options['uploadTable'] = "#{$uploadTable}";
     }
     if (!isset($this->options['downloadTable'])) {
         $downloadTable = "files";
         $this->options['downloadTable'] = "#files";
     } else {
         $downloadTable = $this->options['downloadTable'];
         $this->options['downloadTable'] = "#{$downloadTable}";
     }
     if (!isset($this->options['buildUploadRow'])) {
         $this->options['buildUploadRow'] = $this->_getBuildUploadRow();
     }
     if (!isset($this->options['buildDownloadRow'])) {
         $this->options['buildDownloadRow'] = $this->_getBuildDownloadRow();
     }
     if (!isset($this->htmlOptions['enctype'])) {
         $this->htmlOptions['enctype'] = 'multipart/form-data';
     }
     if (!isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = 'xupload-form file_upload';
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = get_class($model) . "_form";
     }
     $options = CJavaScript::encode($this->options);
     CVarDumper::dumpAsString($options, 10, true);
     Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->htmlOptions['id'], "jQuery('#{$this->htmlOptions['id']}').fileUploadUI({$options});", CClientScript::POS_READY);
     //echo "<pre>";print_r($options);exit();
     echo CHtml::beginForm($this->url, 'post', $this->htmlOptions);
     $htmlOptions = array();
     if ($this->multiple) {
         $htmlOptions["multiple"] = true;
     }
     if ($this->hasModel()) {
         echo CHtml::activeFileField($this->model, $this->attribute, $htmlOptions);
     } else {
         echo CHtml::fileField($name, $this->value, $htmlOptions);
     }
     echo CHtml::tag("button", array(), "Upload", true);
     echo CHtml::tag("div", array(), $this->text, true);
     echo CHtml::endForm();
     if ($uploadTable == $downloadTable) {
         echo CHtml::tag("table", array("id" => $uploadTable), "", true);
     } else {
         echo CHtml::tag("table", array("id" => $uploadTable), "", true);
         echo CHtml::tag("table", array("id" => $downloadTable), "", true);
     }
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:61,代码来源:XUploadWidget.php

示例4: editAttribute

 /**
  * @param $value
  * @return string
  */
 public function editAttribute($model, $field, $params = array())
 {
     if (!isset($params['options'])) {
         $params['options'] = array();
     }
     $options = $params['options'];
     unset($params['options']);
     return CHtml::activeFileField($model, $field->varname, $params) . ($model->getAttribute($field->varname) ? '<br/>' . CHtml::activeCheckBox($model, '[uwfdel]' . $field->varname, $params) . ' ' . CHtml::activeLabelEx($model, '[uwfdel]' . $field->varname, array('label' => UserModule::t('Delete file'), 'style' => 'display:inline;')) : '');
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:13,代码来源:UWfile.php

示例5: run

    public function run()
    {
        $type = DataType::getInputType($this->column->dbType);
        $this->htmlOptions += $this->fixedHtmlOptions[$type];
        $column = $this->column->name;
        $name = isset($this->htmlOptions['name']) ? $this->htmlOptions['name'] : 'Row[' . $column . ']';
        switch ($type) {
            case 'number':
                echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
                break;
            case 'select':
                echo CHtml::activeDropDownList($this->row, $column, $this->getEnumValues(), $this->htmlOptions);
                break;
            case 'select-multiple':
                #echo CHtml::activeListBox($this->row, $column, $this->getSetValues(), $this->htmlOptions);
                echo CHtml::listBox($name, $this->row->getAttributeAsArray($column), $this->getSetValues(), $this->htmlOptions);
                break;
            case 'text':
                echo CHtml::activeTextArea($this->row, $column, $this->htmlOptions);
                break;
            case 'file':
                echo '<script type="text/javascript">
					$(document).ready(function() {
						$("# echo CHtml::$idPrefix; ?>").submit(function() {
							alert("ok1");
							
						});
					});
					</script>';
                echo CHtml::activeFileField($this->row, $column, $this->htmlOptions);
                break;
            case 'date':
                $this->SetDateTimeHtmlOptions($column);
                echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
                echo '<script type="text/javascript">
						$(document).ready(function() {
							$("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd", buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"});
						});
						</script>';
                break;
            case 'datetime':
                $this->SetDateTimeHtmlOptions($column);
                echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
                echo '<script type="text/javascript">
						$(document).ready(function() {
							now = new Date();
							$("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(), buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"});
						});
						</script>';
                break;
            default:
                echo CHtml::activeTextField($this->row, $column, $this->htmlOptions);
                break;
        }
    }
开发者ID:cebe,项目名称:chive,代码行数:55,代码来源:InputField.php

示例6: renderField

 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     $this->htmlOptions = WhHtml::defaultOption('id', $id, $this->htmlOptions);
     $this->htmlOptions = WhHtml::defaultOption('name', $name, $this->htmlOptions);
     $this->htmlOptions['data-url'] = $this->uploadAction;
     if ($this->hasModel()) {
         echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::fileField($name, $this->value, $this->htmlOptions);
     }
 }
开发者ID:crisu83,项目名称:yiiwheels,代码行数:15,代码来源:WhBasicFileUpload.php

示例7: run

 public function run()
 {
     $val = $this->model->{$this->attribute};
     if (!$this->model->isNewRecord && $val) {
         $id = $this->id . get_class($this);
         $files_data = $this->model->uploadFiles();
         $attribute_data = $files_data[$this->attribute];
         $directory = trim($attribute_data['dir'], '/');
         $preview = ImageHelper::thumb($directory, $val, array('width' => null, 'height' => 128));
         $preview .= CHtml::ajaxLink('X', array('/main/helpAdmin/saveAttribute'), array('type' => 'post', 'data' => array('model' => get_class($this->model), 'id' => $this->model->primaryKey, 'attribute' => $this->attribute, 'value' => '', 'unlink_file' => $directory . '/' . $val), 'success' => 'js:function() {$("#' . $id . '").remove();}'), array('class' => 'btn btn-danger delete-img'));
         echo CHtml::tag('div', array('id' => $id), $preview);
     }
     echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:14,代码来源:FileWidget.php

示例8: run

 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id . '-file';
     $containerId = $this->id . '-container';
     $label = '选择文件';
     if ($this->hasModel()) {
         $name = CHtml::activeName($this->model, $this->attribute) . '[]';
         if ($this->form) {
             $label .= $this->form->fileField($this->model, $this->attribute, array('name' => $name, 'id' => $id, 'hideFocus' => true));
         } else {
             $label .= CHtml::activeFileField($this->model, $this->attribute, array('name' => $name, 'id' => $id, 'hideFocus' => true));
         }
     }
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => $label, 'size' => 'small', 'icon' => 'plus', 'encodeLabel' => false, 'htmlOptions' => $this->htmlOptions));
     echo CHtml::tag('div', array('id' => $containerId), '', true);
     Yii::app()->bootstrap->registerAssetCss('bootstrap-file-selector.css');
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('multifile');
     $cs->registerScript(__CLASS__ . '#' . $this->id, "\n\$('#{$id}').MultiFile(" . CJavaScript::encode($this->options) . ")");
 }
开发者ID:ruzuojun,项目名称:shiqu,代码行数:23,代码来源:TbFileSelector.php

示例9: array

        <?php 
echo $form->error($model, 'student_transaction_shift_id');
?>
	</div>

    </div>

    <div class="row">
	      <?php 
echo $form->labelEx($photo, 'student_photos_path');
?>
	      <?php 
CHtml::form('', 'post', array('enctype' => 'multipart/form-data'));
?>
	      <?php 
echo CHtml::activeFileField($photo, 'student_photos_path', array('tabindex' => 15));
?>
<span class="status">&nbsp;</span>
		<?php 
if (isset($photo->student_photos_path)) {
    echo CHtml::image(Yii::app()->baseUrl . '/stud_images/' . $photo->student_photos_path, "", array("width" => "50px", "height" => "50px"));
}
?>
	
	      <?php 
CHtml::endForm();
?>
</div>

<div class="row buttons">
		<?php 
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:31,代码来源:_tab1.php

示例10: array

?>
    <h1>Import settings</h1>


    <?php 
echo CHtml::beginForm($this->createUrl('superadmin/exportadminssettings'), 'post', array('id' => 'formimportadminssettings', 'enctype' => 'multipart/form-data'));
?>
    <?php 
echo CHtml::hiddenField('type', 'import');
?>
    <table class="">
        <tr>
            <th><?php 
echo CHtml::activeLabel($importAdminsSettings, 'imported_file');
?>
:</th>
            <td><?php 
echo CHtml::activeFileField($importAdminsSettings, 'imported_file');
?>
</td>
        </tr>
    </table>
    <br/><br/>
    <?php 
echo CHtml::submitButton('Import');
?>
    <?php 
echo CHtml::endForm();
?>

</div>
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:31,代码来源:exportadminssettings.php

示例11: array

        <?php 
if ($model->isNewRecord) {
    ?>
<img src="/images/nophoto_100_100.jpg"><?php 
} else {
    //Проверяем файл, если нет картинки - ставим заглушку
    $url_img = "/images/nophoto_100_100.jpg";
    if (file_exists(YiiBase::getPathOfAlias('webroot') . $base_url_img . $model->id . '.' . $model->image)) {
        $url_img = $base_url_img . 'small-' . $model->id . '.' . $model->image;
    }
    echo '<a href="' . $base_url_img . $model->id . '.' . $model->image . '" target="_blank"><img src="' . $url_img . '"></a>';
}
?>
        <br>
        <?php 
echo CHtml::activeFileField($model, 'imagefile', array('style' => 'cursor: pointer;'));
?>
    </div>
</div>




<div class="block_url" style="width: 100%; background-color: #3689d8; margin-bottom: 5px; cursor: pointer;">
    <a href="#" data-type="plus"><span style="color: #fff; margin-left: 10px; font-weight: bold;"><img src="/images/admin/icons/plus.gif" style="padding-right: 10px;" />Настройки</span></a>
</div>
<div style="margin-top: 10px; padding: 10px; display: none;">
    <?php 
echo $form->dropDownListRow($model, 'primary', array('0' => 'Нет', '1' => 'Да'), array('class' => 'span5'));
?>
    <?php 
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:31,代码来源:_form.php

示例12:

if ($this->showForm) {
    echo CHtml::beginForm($this->url, 'post', $this->htmlOptions);
}
?>
<div class="row fileupload-buttonbar">
	<div class="span7">
		<!-- The fileinput-button span is used to style the file input field as button -->
		<span class="btn btn-success fileinput-button">
            <i class="icon-plus icon-white"></i>
            <span><?php 
echo $this->t('1#Agregar fotos|0#Choose file', $this->multiple);
?>
</span>
			<?php 
if ($this->hasModel()) {
    echo CHtml::activeFileField($this->model, $this->attribute, $htmlOptions) . "\n";
} else {
    echo CHtml::fileField($name, $this->value, $htmlOptions) . "\n";
}
?>
		</span>
        <?php 
if ($this->multiple) {
    ?>
		<button type="submit" class="btn btn-primary start">
			<i class="icon-upload icon-white"></i>
			<span>Subir</span>
		</button>
		<button type="reset" class="btn btn-warning cancel">
			<i class="icon-ban-circle icon-white"></i>
			<span>Cancelar</span>
开发者ID:rzamarripa,项目名称:ase,代码行数:31,代码来源:form.php

示例13: array

<h2>Image Gallery</h2>
<div class="form">
<?php 
echo CHtml::beginForm('', 'post', array('enctype' => 'multipart/form-data'));
echo CHtml::errorSummary($model);
echo CHtml::activeFileField($model, 'image');
?>
<br>
<?php 
echo CHtml::submitButton('Upload', array('name' => 'submitPost'));
echo CHtml::endForm();
?>
</div><!-- form -->
<br>
<?php 
//$criteria=new CDbCriteria;
//$pages=new CPagination(count($filelist));
//$pages->pageSize=Yii::app()->params['imagesPerPage'];
//$pages->applyLimit($criteria);
$i = 0;
?>

<table class="dataGrid">
  <tr>
    <th><?php 
echo 'Thumbnail';
?>
</th>
    <th><?php 
echo 'File Name';
?>
开发者ID:GowthamThangamani,项目名称:yii-blogdemo-enhanced,代码行数:31,代码来源:gallery.php

示例14: array

							<label>Yes</label>
						</div>						
					</div>
				</div>

				<div class="form-group">
					<label class="<?php 
echo $label_class;
?>
">Doctor Note</label>
					<div class="col-md-6 col-xs-12">
						<?php 
echo CHtml::image($model->getLetter(), 'letter', array('height' => '50px'));
?>
						<?php 
echo CHtml::activeFileField($modelPhoto, 'file', array('class' => 'btn btn-success'));
?>
						<?php 
echo CHtml::error($model, 'doctor_letter_proof');
?>
					</div>					
				</div>

				<div class="form-group">
					<?php 
echo CHtml::activeLabelEx($model, 'number_of_hours', array('class' => $label_class));
?>
					<div class="col-md-6 col-xs-12">
						<?php 
echo CHtml::activeTextField($model, 'number_of_hours', array('class' => 'validate[required] form-control', 'style' => 'width:100px;', 'value' => ''));
?>
开发者ID:qhyabdoel,项目名称:hris_mujigae,代码行数:31,代码来源:_form.php

示例15: array

$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 't_lahir', 'value' => $model->t_lahir, 'options' => array('dateFormat' => 'yy-mm-dd', 'showOn' => 'button', 'yearRange' => '-60', 'changeMonth' => 'ture', 'changeYear' => 'true', 'constrainInput' => 'false', 'duration' => 'fast', 'showAnim' => 'slide'), 'htmlOptions' => array('size' => 20)));
?>
		<?php 
echo $form->error($model, 't_lahir');
?>
	</div>

	<div class="row">
                <?php 
echo $form->labelEx($model, 'foto');
?>
                <?php 
echo "Upload Your's image", "<br>";
?>
                <?php 
echo CHtml::activeFileField($model, 'foto');
?>
                <?php 
echo $form->error($model, 'foto');
?>
         </div>


	<div class="row">
		<?php 
echo $form->labelEx($model, 'gender');
?>
		<?php 
echo $form->dropDownList($model, 'gender', User::gender(), array('prompt' => '- Choose -', 'style' => 'width: 200px; '));
?>
		<?php 
开发者ID:jumper2012,项目名称:english_learning,代码行数:31,代码来源:_form.php


注:本文中的CHtml::activeFileField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。