當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CActiveForm::fileField方法代碼示例

本文整理匯總了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);
 }
開發者ID:bruno-melo,項目名稱:components,代碼行數:9,代碼來源:MyActiveForm.php

示例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') . '&nbsp;&nbsp;</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;
 }
開發者ID:kostya1017,項目名稱:our,代碼行數:71,代碼來源:UploadingBehavior.php

示例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);
 }
開發者ID:codemix,項目名稱:restyii,代碼行數:13,代碼來源:ActiveForm.php

示例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);
 }
開發者ID:nov072008,項目名稱:yiitesting,代碼行數:12,代碼來源:WForm.php


注:本文中的CActiveForm::fileField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。