本文整理汇总了PHP中CHtml::fileField方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::fileField方法的具体用法?PHP CHtml::fileField怎么用?PHP CHtml::fileField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::fileField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formInput
public function formInput(&$controller, $tagOptions=array())
{
ob_start();
$inputName = $this->formInputName();
$inputID = "i_{$inputName}";
echo CHtml::label($this->label, $inputID);
echo CHtml::tag('br');
if($this->isReadonly)
$tagOptions['disabled'] = true;
if($this->value)
{
$oldOptions = array('readonly'=>true);
if($this->isReadonly)
$tagOptions['disabled'] = true;
echo CHtml::textField("{$inputName}[old]", $this->value, $oldOptions);
unset($oldOptions['readonly']);
?>
<label class="delfile">
<?php echo Yii::t('AutoAdmin.form', '<b class="warning">Delete</b> the file')?> <span class="tip">(<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>)</span>:
<?php echo CHtml::checkBox("{$inputName}[del]", false, $oldOptions);?>
</label>
<?php
}
$tagOptions['id'] = $inputID;
echo CHtml::label(Yii::t('AutoAdmin.form', 'New file').':', $inputID);
?>
<div class="tip inline"><a href=<?php echo $this->options['directoryPath']?>/</div>
<?php
echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions);
return ob_get_clean();
}
示例2: renderField
/**
* @param $attribute
* @param null $value
* @param null $name
* @param array $htmlOptions
* @return mixed|null|string
*/
public static function renderField($attribute, $value = null, $name = null, $htmlOptions = [])
{
$name = $name ?: 'Attribute[' . $attribute->id . ']';
switch ($attribute->type) {
case Attribute::TYPE_SHORT_TEXT:
return CHtml::textField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_TEXT:
return Yii::app()->getController()->widget(Yii::app()->getModule('store')->getVisualEditor(), ['name' => $name, 'value' => $value], true);
break;
case Attribute::TYPE_DROPDOWN:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::dropDownList($name, $value, $data, array_merge($htmlOptions, ['empty' => '---']));
break;
case Attribute::TYPE_CHECKBOX_LIST:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::checkBoxList($name . '[]', $value, $data, $htmlOptions);
break;
case Attribute::TYPE_CHECKBOX:
return CHtml::checkBox($name, $value, CMap::mergeArray(['uncheckValue' => 0], $htmlOptions));
break;
case Attribute::TYPE_NUMBER:
return CHtml::numberField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_FILE:
return CHtml::fileField($name . '[name]', null, $htmlOptions);
break;
}
return null;
}
示例3: run
/**
* Runs the widget.
* This method registers all needed client scripts and renders
* the multiple file uploader.
*/
public function run()
{
if ($this->name !== null) {
$name = $this->name;
} else {
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
throw new CException(Yii::t('yii', 'CMultiFileUpload.name is required.'));
}
}
if (substr($name, -2) !== '[]') {
$name .= '[]';
}
if (($id = $this->getId(false)) === null) {
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$id = CHtml::getIdByName($name);
}
}
$this->htmlOptions['id'] = $id;
$this->registerClientScript();
echo CHtml::fileField($name, '', $this->htmlOptions);
}
示例4: 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);
}
}
示例5: run
/**
* Generates the required HTML and Javascript
*/
public function run()
{
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 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(), "Upload file", 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);
}
}
示例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);
}
}
示例7: run
/**
* Runs the widget.
* This method registers all needed client scripts and renders
* the multiple file uploader.
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
if (substr($name, -2) !== '[]') {
$name .= '[]';
}
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
$this->registerClientScript();
echo CHtml::fileField($name, '', $this->htmlOptions);
}
示例8: field
private static function field($key, $value, $sModel, $model)
{
if (strpos($sModel, "listT(") === 0) {
$modelName = str_replace("listT(", "", $sModel);
$modelName = str_replace(")", "", $modelName);
$type = substr($modelName, strpos($modelName, '[') + 1, strpos($modelName, '[') - strpos($modelName, ']') + 1);
//echo $type;
//exit;
$modelName = str_replace("[" . $type . "]", "", $modelName);
$temp = CHtml::listData($modelName::model()->findAllByType($type), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $temp) . "<br/>";
} elseif (strpos($sModel, "list(") === 0) {
$modelName = str_replace("list(", "", $sModel);
$modelName = str_replace(")", "", $modelName);
$temp = CHtml::listData($modelName::model()->findAll(), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $temp) . "<br/>";
} elseif (strpos($sModel, "select(") === 0) {
$list = str_replace("select(", "", $sModel);
$list = CJSON::decode(str_replace(")", "", $list));
foreach ($list as &$item) {
//print $item;
$item = Yii::t('app', $item);
}
//$temp = CHtml::listData(CJSON::decode($list), 'id', 'name');
$temp[''] = Yii::t('app', 'None');
//$label = Yii::t('app', $sModel->id);
$field = CHtml::dropDownList($model . '[' . $key . '][value]', $value, $list) . "<br/>";
} elseif ($sModel == 'file') {
//$label = Yii::t('app', $sModel->id) ;
$field = CHtml::fileField($model . '[' . $key . '][value]', $value) . CHtml::hiddenField($model . '[' . $key . '][value]', $value) . "<a href='javascript:del();'>" . Yii::t('app', 'Delete') . "</a><br />";
} elseif ($sModel == 'boolean') {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::hiddenField($model . '[' . $key . '][value]', false) . CHtml::checkbox($model . '[' . $key . '][value]', $value == 'true' ? true : false);
} elseif ($sModel == 'date') {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::textField($model . '[' . $key . '][value]', $value, array('class' => 'date'));
$name = str_replace("[", "_", str_replace("]", "_", $model));
$field .= "<script>\njQuery('#{$name}{$key}_value').datepicker();</script>";
} else {
//$label = Yii::t('app', $sModel->id);
$field = CHtml::textField($model . '[' . $key . '][value]', $value);
}
return $field;
}
示例9: actionIndex
public function actionIndex($path = '/')
{
$fsw = new FilesystemWrapper('/home/rosko/WWW/hosts/test/public_html/test/', array('baseUrl' => 'http://test/test/'));
$fsw->filter = array('excludeHidden' => true);
$fsw->sort = array('directoriesFirst' => true);
if ($fsw) {
echo CHtml::beginForm('', 'post', array('enctype' => 'multipart/form-data'));
echo CHtml::fileField('file');
echo CHtml::submitButton();
echo CHtml::endForm();
if (CUploadedFile::getInstanceByName('file')) {
echo $fsw->uploadFile('/', 'file', true, 'upload.jpg');
}
//echo $fsw->delete('/mydir.txt');
//print_r ($fsw->createFile('/', 'mydir.txt', 'sdfsdfsвавів'));
print_r($fsw->getDirectory($path));
}
}
示例10: run
/**
* Make the code to be inserted in the view
*/
public function run()
{
$clientScript = Yii::app()->getClientScript();
$dir = dirname(__FILE__);
$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);
// $clientScript->registerScriptFile($this->baseUrl . '/uploadify-v3.1/swfobject.js', CClientScript::POS_HEAD);
// $clientScript->registerScriptFile($this->baseUrl . '/uploadify-v3.1/jquery.uploadify-3.1.min.js', CClientScript::POS_HEAD);
// $clientScript->registerCssFile($this->baseUrl . '/uploadify-v3.1/uploadify.css');
list($name, $id) = $this->resolveNameID();
$options = $this->makeOptions();
$js = <<<EOP
\$("#{$id}").uploadify({$options});
EOP;
$clientScript->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_READY);
$this->htmlOptions['id'] = $id;
$this->htmlOptions['name'] = $id;
$this->htmlOptions['type'] = 'file';
// $html = CHtml::tag('input', $this->htmlOptions, $this->body);
$html = CHtml::fileField($id, null, $this->htmlOptions);
echo $html;
}
示例11: array
<label><?php
echo 'Manual outcome to update:';
?>
</label>
<?php
echo CHtml::dropDownList('outcome_id', null, CHtml::listData($Outcomes, 'id', 'name'), array('class' => 'form-control', (sizeof($Outcomes) ? 'not' : '') . 'disabled' => 'disabled'));
?>
</div>
<div class="form-group">
<label><?php
echo 'User id csv file:';
?>
</label>
<?php
echo CHtml::fileField('file', '', array('class' => 'form-control', (sizeof($Outcomes) ? 'not' : '') . 'disabled' => 'disabled'));
?>
</div>
<div class="">
<?php
echo CHtml::submitButton('Upload', array('class' => 'btn btn-primary', (sizeof($Outcomes) ? 'not' : '') . 'disabled' => 'disabled'));
?>
<?php
echo CHtml::link('cancel', array('campaign/result', 'id' => $Campaign->id), array('class' => 'btn'));
?>
</div>
<?php
$this->endWidget();
?>
示例12: array
echo CHtml::fileField('data', '', array('id' => 'data')) . "<br>";
echo CHtml::hiddenField('model', $model);
echo "<i>" . Yii::t('app', 'Allowed filetypes: .csv') . "</i><br><br>";
echo "<h3>" . Yii::t('admin', 'Import Map') . " <a class='pseudo-link' id='toggle-map-upload'>" . X2Html::fa('fa-caret-down') . "</a></h3>";
echo "<div id='upload-map' style='display:none;'>";
echo Yii::t('admin', "You may select a predefined map here, or upload your own.") . "<br />";
$availImportMaps = $this->availableImportMaps($model);
if (empty($availImportMaps)) {
echo "<div style='color:red'>";
echo Yii::t('app', "No related import maps were found.");
echo "</div>";
} else {
echo CHtml::radioButtonList('x2maps', null, $availImportMaps, array('labelOptions' => array('style' => 'display:inline')));
}
echo "<br /><br />";
echo CHtml::fileField('mapping', '', array('id' => 'mapping')) . "<br>";
echo "<i>" . Yii::t('app', 'Allowed filetypes: .json') . "</i>";
echo "</div><br><br>";
echo CHtml::submitButton(Yii::t('app', 'Submit'), array('class' => 'x2-button'));
echo CHtml::endForm();
echo "</div>";
} else {
echo "<h3>" . Yii::t('admin', 'Please select a module to import records into.') . "</h3>";
foreach ($modelList as $class => $modelName) {
echo CHtml::link($modelName, array('/admin/importModels', 'model' => $class)) . "<br />";
}
}
?>
</div>
<script>
示例13: array
<?php
echo CHtml::form($model->formTarget, 'post', array('id' => 'Import'));
?>
<?php
echo CHtml::hiddenField("MAX_FILE_SIZE", ConfigUtil::getMaxUploadSize() - 1000);
?>
<?php
echo CHtml::hiddenField("Import", "true");
?>
<fieldset>
<legend><?php
echo Yii::t('core', 'importFile');
?>
</legend>
<?php
echo CHtml::fileField('file', '', array());
?>
(<?php
echo Yii::t('core', 'maximum');
?>
: <?php
echo ConfigUtil::getMaxUploadSize(true);
?>
)
<br />
<br />
<?php
//echo Yii::t('core', 'characterSet', array(1));
?>
<br />
示例14: array
<div class="row">
<div class="col-lg-12 content-right">
<?php
echo CHtml::form(array("admin/tokens/sa/import/surveyid/{$iSurveyId}"), 'post', array('id' => 'tokenimport', 'name' => 'tokenimport', 'class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));
?>
<!-- Choose the CSV file to upload -->
<div class="form-group">
<label class="col-sm-2 control-label" for='the_file'><?php
eT("Choose the CSV file to upload:");
?>
</label>
<div class="col-sm-10">
<?php
echo CHtml::fileField('the_file', '', array('required' => 'required', 'accept' => '.csv'));
?>
</div>
</div>
<!-- "Character set of the file -->
<div class="form-group">
<label class="col-sm-2 control-label" for='csvcharset'><?php
eT("Character set of the file:");
?>
</label>
<div class="col-sm-5">
<?php
echo CHtml::dropDownList('csvcharset', 'auto', $aEncodings, array('size' => '1', 'class' => 'form-control'));
?>
</div>
示例15: array
}
?>
<div style="display: none;" id="td_upload_form_block">
<?php
echo CHtml::fileField('reviews', null, array('class' => 'normal'));
?>
</div>
<?php
echo CHtml::link(Yii::t('app', 'Отмена'), 'javascript:void(0)', array('id' => 'td_upload_link_cancel', 'style' => 'display: none;'));
?>
<?php
} else {
?>
<div style="display: block;" id="td_upload_form_block">
<?php
echo CHtml::fileField('reviews', null, array('class' => 'normal'));
?>
</div>
<?php
}
?>
</div>
</div>
<?php
if ($reviewsSettings->is_allowed_show_at_home) {
?>
<tr>
<td width ="150"><?php
echo CHtml::activeLabelEx($model, 'show_at_home');