本文整理汇总了PHP中CActiveForm::fileField方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveForm::fileField方法的具体用法?PHP CActiveForm::fileField怎么用?PHP CActiveForm::fileField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveForm
的用法示例。
在下文中一共展示了CActiveForm::fileField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fileField
public function fileField($model, $attribute, $htmlOptions = array())
{
$limit = 1;
if (isset($htmlOptions['limit'])) {
$limit = $htmlOptions['limit'];
unset($htmlOptions['limit']);
}
return parent::fileField($model, $attribute, $htmlOptions);
}
示例2: makeField
/**
* Echos or returns the file field, temp name hidden field, the delete checkbox and preview image and set up the uploadcare widget if used.
*
* @param CActiveForm $form the form in which the widget is called. Can be null if CActiveForm is not used. Defaults to null in parent class.
*
* @param boolean $return whether to return the html or just echo it. Defaults to false in parent class.
*
* @param string $attributePostName the fields name if non standard. Such as if using array notation. The format is [key1][key2][keyn...]attributeName, no class name. Defaults to null in parent class.
*
* @param array $fileFieldHtmlOptions html options for file field. Defaults to empty array in parent class.
*
* @param array $checkboxHtmlOptions html options for checkbox field. Defaults to empty array in parent class.
*
* @param array $previewImageHtmlOptions html options for preview image. Defaults to empty array in parent class.
*
* @return string the html.
*/
public function makeField($form, $attributePostName, $fileFieldHtmlOptions, $checkboxHtmlOptions, $previewImageHtmlOptions)
{
$behavior = $this->_behavior;
$owner = $behavior->owner;
$attribute = $behavior->attribute;
$ownerClass = get_class($owner);
$html = '';
if (isset($attributePostName)) {
$postAttributeArrays = substr($attributePostName, 0, strrpos($attributePostName, ']') + 1);
} else {
$postAttributeArrays = '';
}
foreach ($owner->behaviors() as $ownerBehaviorName => $ownerBehaviorParams) {
if (($ownerBehaviorParams['class'] == 'application.components.behaviors.UploadingBehavior.ActiveRecordUploadingBehavior' || $ownerBehaviorParams['class'] == 'application.components.behaviors.UploadingBehavior.ModelUploadingBehavior') && $ownerBehaviorParams['attribute'] == $behavior->attribute) {
$behaviorName = $ownerBehaviorName;
break;
}
}
$html .= '<div class="uploadFieldWrap">';
if ($owner->{$attribute} != '') {
if ($behavior->showPreviewImage) {
$html .= CHtml::image(Yii::app()->request->baseUrl . '/' . ($owner->{$behaviorName}->tempName != '' ? $owner->{$behaviorName}->tempDir . '/' . $this->fileSuffix($owner->{$behaviorName}->tempName, $behavior->previewImageSuffix) : $owner->{$behaviorName}->dir . '/' . $this->fileSuffix($owner->{$attribute}, $behavior->previewImageSuffix)), '', $previewImageHtmlOptions);
}
if ($behavior->allowDelete) {
$html .= CHtml::checkbox($ownerClass . $postAttributeArrays . '[' . $behaviorName . '][delete]', $behavior->delete, $checkboxHtmlOptions) . '<span>' . Yii::t('admin', 'Supprimer ou') . ' </span>';
}
$html .= CHtml::hiddenField($ownerClass . $postAttributeArrays . '[' . $behaviorName . '][tempName]', $behavior->tempName);
}
if ($behavior->uploadcare !== null) {
Yii::app()->clientScript->registerScript('UploadingBehaviorUploadCarePublicKey', "UPLOADCARE_PUBLIC_KEY = '" . $this->_uploadcareApi->getPublicKey() . "'; UPLOADCARE_LOCALE = '" . (isset($behavior->uploadcare['language']) ? $behavior->uploadcare['language'] : Yii::app()->language) . "';", CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->_uploadcareApi->widget->getScriptSrc(), CClientScript::POS_HEAD);
$options = array('role' => 'uploadcare-uploader');
$uploadcareArr = $behavior->uploadcare;
unset($uploadcareArr['publicKey']);
unset($uploadcareArr['privateKey']);
unset($uploadcareArr['language']);
$options = array_merge($options, $uploadcareArr);
if (!isset($options['data-images-only']) && isset($behavior->formats)) {
$options['data-images-only'] = 'true';
}
if (!isset($options['data-crop']) && isset($behavior->formats)) {
$options['data-crop'] = 'true';
}
$html .= CHtml::hiddenField($ownerClass . $postAttributeArrays . '[' . $attribute . ']', '', $options);
} else {
if ($form !== null) {
$html .= $form->fileField($owner, $postAttributeArrays . $attribute, $fileFieldHtmlOptions);
} else {
$html .= CHtml::activeFileField($owner, $postAttributeArrays . $attribute, $fileFieldHtmlOptions);
}
}
$html .= '</div>';
return $html;
}
示例3: fileField
/**
* @inheritDoc
*/
public function fileField($model, $attribute, $htmlOptions = array())
{
if (!$this->qualifyNames && !isset($htmlOptions['name'])) {
$htmlOptions['name'] = $attribute;
}
if (!isset($htmlOptions['itemprop'])) {
$htmlOptions['itemprop'] = $this->getItemPropName($attribute);
}
return parent::fileField($model, $attribute, $htmlOptions);
}
示例4: fileField
/**
* Renders a file field for a model attribute.
* @param CModel $parentModel the parent data model
* @param string $attributedPath the attribute or path to related model attribute
* @param array $htmlOptions additional HTML attributes
* @return string the generated input field
*/
public function fileField($parentModel, $attributedPath, $htmlOptions = array())
{
list($model, $attribute, $htmlOptions) = self::resolveArgs($parentModel, $attributedPath, $htmlOptions);
return parent::fileField($model, $attribute, $htmlOptions);
}