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


PHP UploadField::setCanAttachExisting方法代碼示例

本文整理匯總了PHP中UploadField::setCanAttachExisting方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadField::setCanAttachExisting方法的具體用法?PHP UploadField::setCanAttachExisting怎麽用?PHP UploadField::setCanAttachExisting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UploadField的用法示例。


在下文中一共展示了UploadField::setCanAttachExisting方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $requiredFields = null;
     if ($member && $member->exists()) {
         $fields = new FieldList();
         $fields->add(new HeaderField('AddressHeader', _t('Addressable.ADDRESSHEADER', 'Avatar / Description')));
         $uploadField = new UploadField('Avatar', 'Select avatar');
         $uploadField->setCanAttachExisting(false);
         $comment = new TextareaField('Description', 'Description*');
         $email = EmailField::create('Email', _t('CheckoutField.EMAIL', 'Email'));
         $fields->add($uploadField);
         $fields->add($comment);
         $fields->add($email);
         $requiredFields = $member->getValidator();
         $requiredFields->addRequiredField('Avatar', 'Description', 'Email');
     } else {
         $fields = new FieldList();
     }
     if (get_class($controller) == 'ChefAccountPage_Controller') {
         $actions = new FieldList(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')));
     }
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     if ($member) {
         $member->Password = "";
         //prevents password field from being populated with encrypted password data
         $this->loadDataFrom($member);
     }
     if ($record = $controller->data()) {
         $record->extend('updateChefAccountForm', $fields, $actions, $requiredFields);
     }
 }
開發者ID:8secs,項目名稱:cocina,代碼行數:32,代碼來源:ChefAccountForm.php

示例2: getUploadForm

 public static function getUploadForm($file, $parentClass, $parentId, $parentField)
 {
     if ($file instanceof File && class_exists($parentClass) && is_subclass_of($parentClass, "DataObject")) {
         $parent = $parentClass::get()->byId($parentId);
         $fields = new FieldList($uploadField = new UploadField($parentField, 'Upload', $parent));
         $uploadField->setCanAttachExisting(false);
         // Block access to Silverstripe assets library
         $uploadField->setCanPreviewFolder(false);
         // Don't show target filesystem folder on upload field
         $uploadField->relationAutoSetting = false;
         // Prevents the form thinking the GalleryPage is the underlying object
         $uploadField->setFolderName('Address Book');
         $uploadField->setAllowedMaxFileNumber(1);
         if ($file instanceof Image) {
             $uploadField->setAllowedFileCategories('image');
         }
         $actions = new FieldList(new FormAction('submit', 'Save'));
         $from = new Form(Controller::curr(), 'feFileUploadForm', $fields, $actions, null);
         $urlParams = array('feclass' => $parentClass, 'fefield' => $parentField, 'feid' => $parentId, 'filesUpload' => true, 'fefileid' => $file->ID, 'fefileclass' => $file->ClassName);
         //   feclass: parentClass,
         //                        fefield: parentField,
         //                        feid: parentId,
         //                        feisUpload: true,
         //                        value: "{feclass: " + objClass + ",feid: " + objId + "}"
         //            echo http_build_query($urlParams) . "\n";
         $from->setFormAction('home/feFileUploadForm?' . http_build_query($urlParams));
         return $from;
     }
 }
開發者ID:helpfulrobot,項目名稱:gdmedia-silverstripe-frontend-admin,代碼行數:29,代碼來源:FrontendEditing.php

示例3: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->add(new TextField('AddEntityText', 'Add Text'));
     $fields->add(new TextField('DeleteEntityText', 'Delete Text'));
     $fields->add(new TextField('EditEntityText', 'Edit Text'));
     $icon = new UploadField('EntityIcon', 'Upload Entity Icon');
     $icon->setCanAttachExisting(false);
     $icon->setAllowedMaxFileNumber(1);
     $icon->setAllowedFileCategories('image');
     $icon->setFolderName('survey-builder');
     if ($this->ID > 0) {
         $fields->add($icon);
         $id = (int) $this->ID;
         $parent_id = (int) $this->SurveyTemplateID;
         $fields->add($ddl_entity = new DropdownField('EntityID', 'Please choose an entity to hold', EntitySurveyTemplate::get()->where(" (OwnerID = 0 OR OwnerID = {$id} ) AND ParentID = {$parent_id} ")->map("ID", "EntityName")));
         $ddl_entity->setEmptyString('-- Please Select --');
     }
     return $fields;
 }
開發者ID:rbowen,項目名稱:openstack-org,代碼行數:20,代碼來源:SurveyDynamicEntityStepTemplate.php


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