本文整理汇总了PHP中FileField类的典型用法代码示例。如果您正苦于以下问题:PHP FileField类的具体用法?PHP FileField怎么用?PHP FileField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setAttribute
/**
* Determine if it is a URL upload or file upload.
* Upload the file and set file name
*
* @param $key
* @param $value
*/
public function setAttribute($key, $value)
{
if (in_array($key, array_keys($this->fileFields)) && $value) {
// If valid URL and file exists, download it
if (filter_var($value, FILTER_VALIDATE_URL)) {
$headers = @get_headers($value);
if (strpos($headers[0], '200') || strpos($headers[0], '301') || strpos($headers[0], '302')) {
$fileName = pathinfo($value, PATHINFO_FILENAME);
$extension = pathinfo($value, PATHINFO_EXTENSION);
$fullFileName = join('.', [$fileName, $extension]);
$fileField = new FileField($this, $key, $fullFileName);
$this->attributes[$key] = $fileField->uploadRemoteFile($value);
}
} elseif ($value instanceof UploadedFile) {
$fileName = str_slug(pathinfo($value->getClientOriginalName(), PATHINFO_FILENAME));
$extension = $value->getClientOriginalExtension();
$fullFileName = join('.', [$fileName, $extension]);
$fileField = new FileField($this, $key, $fullFileName);
$this->attributes[$key] = $fileField->uploadFile($value);
} elseif (is_string($value)) {
$fileName = pathinfo($value, PATHINFO_FILENAME);
$extension = pathinfo($value, PATHINFO_EXTENSION);
$fullFileName = join('.', [$fileName, $extension]);
$fileField = new FileField($this, $key, $fullFileName);
$this->attributes[$key] = $fileField->copyLocal($value);
}
} else {
parent::setAttribute($key, $value);
}
}
开发者ID:jaysson,项目名称:eloquent_filefield,代码行数:37,代码来源:FileFieldTrait.php
示例2: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
$helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the
imported file</li>
<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
cleared.</li>
</ul>
</div>');
$importer = new GroupCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if (!$actions) {
$action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('CsvFile');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:33,代码来源:GroupImportForm.php
示例3: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
$helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if (!$actions) {
$action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('CsvFile');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
开发者ID:maent45,项目名称:redefine_renos,代码行数:25,代码来源:MemberImportForm.php
示例4: getFormField
public function getFormField()
{
$field = new FileField($this->Name, $this->Title);
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
return $field;
}
开发者ID:prostart,项目名称:erics-homes,代码行数:11,代码来源:EditableFileField.php
示例5: CreateHeatmapForm
public function CreateHeatmapForm()
{
$includeWatermark = array("1" => "Yes,Include Watermark", "0" => "No,Remove Watermark");
$fields = new FieldList($imageField = new FileField('OriginalImage', 'Upload an Image File'), new LiteralField('UploadInfo', 'Acceptable images are jpg or png, 500-1600 pixels wide by 500-1200 pixels height.<hr>'), new OptionsetField('IncludeWatermark', 'Include Watermark?', $includeWatermark, 1));
$imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
$imageField->setAttribute('class', 'jfilestyle');
$imageField->setAttribute('data-buttonText', "<img src='themes/attwiz/images/button-create-heatmap-browse.jpg'></img>");
$imageField->setAttribute('data-placeholder', 'No file selected..');
// Create action
$actions = new FieldList($submit = new FormAction('processCreateHeatmap', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button-create-heatmap-blue-bg.jpg');
// Create action
$validator = new RequiredFields('OriginalImage', 'IncludeWatermark');
return new Form($this, 'CreateHeatmapForm', $fields, $actions, $validator);
}
开发者ID:hemant-chakka,项目名称:awss,代码行数:15,代码来源:CreateHeatmap.php
示例6: __construct
public function __construct()
{
parent::__construct('goal-edit-form');
$this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
$lang = OW::getLanguage();
$id = new HiddenField('projectId');
$id->setRequired(true);
$this->addElement($id);
$name = new TextField('name');
$name->setRequired(true);
$name->setLabel($lang->text('ocsfundraising', 'name'));
$this->addElement($name);
$btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
$desc = new WysiwygTextarea('description', $btnSet);
$desc->setRequired(true);
$sValidator = new StringValidator(1, 50000);
$desc->addValidator($sValidator);
$desc->setLabel($lang->text('ocsfundraising', 'description'));
$this->addElement($desc);
$category = new Selectbox('category');
$category->setLabel($lang->text('ocsfundraising', 'category'));
$list = OCSFUNDRAISING_BOL_Service::getInstance()->getCategoryList();
if ($list) {
foreach ($list as $cat) {
$category->addOption($cat->id, $lang->text('ocsfundraising', 'category_' . $cat->id));
}
}
$this->addElement($category);
$target = new TextField('target');
$target->setRequired(true);
$target->setLabel($lang->text('ocsfundraising', 'target_amount'));
$this->addElement($target);
$min = new TextField('min');
$min->setLabel($lang->text('ocsfundraising', 'min_amount'));
$min->setValue(1);
$this->addElement($min);
$end = new DateField('end');
$end->setMinYear(date('Y'));
$end->setMaxYear(date('Y') + 2);
$end->setLabel($lang->text('ocsfundraising', 'end_date'));
$this->addElement($end);
$imageField = new FileField('image');
$imageField->setLabel($lang->text('ocsfundraising', 'image_label'));
$this->addElement($imageField);
$submit = new Submit('edit');
$submit->setLabel($lang->text('ocsfundraising', 'edit'));
$this->addElement($submit);
}
开发者ID:vazahat,项目名称:dudex,代码行数:48,代码来源:goal_edit_form.php
示例7: testUploadMissingRequiredFile
/**
* Test different scenarii for a failed upload : an error occured, no files where provided
*/
public function testUploadMissingRequiredFile()
{
$form = new Form(new Controller(), 'Form', new FieldSet($fileField = new FileField('cv', 'Upload your CV')), new FieldSet(), new RequiredFields('cv'));
// All fields are filled but for some reason an error occured when uploading the file => fails
$fileFieldValue = array('name' => 'aCV.txt', 'type' => 'application/octet-stream', 'tmp_name' => '/private/var/tmp/phpzTQbqP', 'error' => 1, 'size' => 3471);
$fileField->setValue($fileFieldValue);
$this->assertFalse($form->validate(), 'An error occured when uploading a file, but the validator returned true');
// We pass an empty set of parameters for the uploaded file => fails
$fileFieldValue = array();
$fileField->setValue($fileFieldValue);
$this->assertFalse($form->validate(), 'An empty array was passed as parameter for an uploaded file, but the validator returned true');
// We pass an null value for the uploaded file => fails
$fileFieldValue = null;
$fileField->setValue($fileFieldValue);
$this->assertFalse($form->validate(), 'A null value was passed as parameter for an uploaded file, but the validator returned true');
}
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:19,代码来源:FileFieldTest.php
示例8: display
static function display($files)
{
$html = "";
foreach ($files as $file) {
$html .= FileField::display($file);
}
return $html;
}
开发者ID:mawilliamson,项目名称:version-control,代码行数:8,代码来源:FileWrapper.class.php
示例9: getFormField
public function getFormField()
{
$field = FileField::create($this->Name, $this->EscapedTitle)->setFieldHolderTemplate('UserFormsField_holder')->setTemplate('UserFormsFileField');
$field->getValidator()->setAllowedExtensions(array_diff(array_filter(Config::inst()->get('File', 'allowed_extensions')), $this->config()->allowed_extensions_blacklist));
$folder = $this->Folder();
if ($folder && $folder->exists()) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
$this->doUpdateFormField($field);
return $field;
}
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:11,代码来源:EditableFileField.php
示例10: Form
function Form()
{
if ($this->request->requestVar('_REDIRECT_BACK_URL')) {
$url = $this->request->requestVar('_REDIRECT_BACK_URL');
} else {
if ($this->request->getHeader('Referer')) {
$url = $this->request->getHeader('Referer');
} else {
$url = Director::baseURL();
}
}
$folder = Folder::find_or_make("ErrorScreenshots");
$whatDidYouTryDoField = new TextareaField('WhatDidYouTryToDo', 'What did you try to do');
$whatDidYouTryDoField->setRows(3);
$whatWentWrongField = new TextareaField('WhatWentWrong', 'What went wrong');
$whatWentWrongField->setRows(3);
$screenshotField = new FileField('Screenshot', 'To take a screenshot press the PRT SCR button on your keyboard, then open MS Word or MS Paint and paste the screenshot. Save the file and then attach (upload) the file here.');
$screenshotField->setFolderName($folder->Name);
$form = new Form($this, 'Form', new FieldList(new TextField('Name'), new TextField('Email'), new TextField('URL', 'What is the URL of the page the error occured (this is the address shown in the address bar (e.g. http://www.mysite.com/mypage/with/errors/)', $url), $whatDidYouTryDoField, $whatWentWrongField, $screenshotField), new FieldList(new FormAction('senderror', 'Submit Error')), new RequiredFields(array("Email", "Name")));
return $form;
}
开发者ID:helpfulrobot,项目名称:sunnysideup-templateoverview,代码行数:21,代码来源:ErrorNotifierController.php
示例11: __construct
/**
* Class constructor
*/
public function __construct($tpls)
{
parent::__construct('edit-template-form');
$this->setAction(OW::getRouter()->urlFor('VIRTUALGIFTS_CTRL_Admin', 'editTemplate'));
$single = count($tpls) == 1;
$this->setEnctype('multipart/form-data');
$language = OW::getLanguage();
$giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
if ($single) {
$file = new FileField('file');
$file->setLabel($language->text('virtualgifts', 'gift_image'));
$this->addElement($file);
$tpl = $giftService->findTemplateById($tpls[0]);
}
$tplId = new HiddenField('tplId');
$tplId->setRequired(true);
$tplId->setValue(implode('|', $tpls));
$this->addElement($tplId);
if ($giftService->categoriesSetup()) {
$categories = new Selectbox('category');
$categories->setLabel($language->text('virtualgifts', 'category'));
$categories->setOptions($giftService->getCategories());
if ($single && isset($tpl)) {
$categories->setValue($tpl->categoryId);
}
$this->addElement($categories);
}
if (OW::getPluginManager()->isPluginActive('usercredits')) {
$price = new TextField('price');
$price->setLabel($language->text('virtualgifts', 'gift_price'));
if ($single && isset($tpl)) {
$price->setValue($tpl->price);
}
$this->addElement($price);
}
// submit
$submit = new Submit('save');
$submit->setValue($language->text('virtualgifts', 'btn_save'));
$this->addElement($submit);
}
开发者ID:hardikamutech,项目名称:loov,代码行数:43,代码来源:template_edit.php
示例12: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('ExcelGroupImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Group')));
$helpHtml .= _t('ExcelGroupImportForm.Help2', '<ul>' . '<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the ' . 'imported file</li>' . '<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>' . '<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not ' . 'cleared.</li>' . '</ul>');
$importer = new GroupCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelGroupImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if (!$actions) {
$action = new FormAction('doImport', _t('ExcelGroupImportForm.BtnImport', 'Import from file'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('File');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:24,代码来源:ExcelGroupImportForm.php
示例13: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('ExcelMemberImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Member')));
$helpHtml .= _t('ExcelMemberImportForm.Help2', '<ul>' . '<li>Existing users are matched by their unique <em>Email</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>');
$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelMemberImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
$fileField->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
}
if (!$actions) {
$action = new FormAction('doImport', _t('ExcelMemberImportForm.BtnImport', 'Import from file'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('File');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:24,代码来源:ExcelMemberImportForm.php
示例14: MessageForm
public function MessageForm($request = null, $itemID = 0)
{
if ($itemID == 0) {
$itemID = isset($_REQUEST['ToMemberID']) ? $_REQUEST['ToMemberID'] : 0;
}
$mergeText = "<ul><li>{" . implode("}</li><li>{", PostmarkHelper::MergeTags()) . "}</li></ul>";
$form = new Form($this, 'MessageForm', new FieldList(array(ObjectSelectorField::create('ToMemberID', 'To:')->setValue($itemID)->setSourceObject(Config::inst()->get('PostmarkAdmin', 'member_class'))->setDisplayField('Email'), DropdownField::create('FromID', 'From')->setSource(PostmarkSignature::get()->filter('IsActive', 1)->map('ID', 'Email')->toArray()), TextField::create('Subject'), QuillEditorField::create('Body'), LiteralField::create('MergeTypes', '<div class="varialbes toggle-block">
<h4>Merge Values</h4>
<div class="contents">' . $mergeText . '</div>
</div>'), HiddenField::create('InReplyToID')->setValue(isset($_REQUEST['ReplyToMessageID']) ? $_REQUEST['ReplyToMessageID'] : 0), FileField::create('Attachment_1', 'Attachment One'), FileField::create('Attachment_2', 'Attachment Two'), FileField::create('Attachment_3', 'Attachment Three'), FileField::create('Attachment_4', 'Attachment Four'), FileField::create('Attachment_5', 'Attachment Five'))), new FieldList(FormAction::create('postmessage', 'Sent Message')));
$requiredField = new RequiredFields(array('FromID', 'Subject', 'Body'));
$form->setValidator($requiredField);
$this->extend('updateMessageForm', $form, $itemID);
$form->setFormAction($this->Link('PostmarkMessage/MessageForm'));
return $form;
}
开发者ID:bueckl,项目名称:postmarkedapp,代码行数:16,代码来源:PostmarkAdmin.php
示例15: getFormField
public function getFormField()
{
$field = FileField::create($this->Name, $this->Title);
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
if ($this->Required) {
// Required validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
}
return $field;
}
开发者ID:8secs,项目名称:cocina,代码行数:18,代码来源:EditableFileField.php
示例16: FoundationForm
function FoundationForm()
{
$fields = new FieldList(HeaderField::create('FormFieldsHeader', 'Form Fields', 3), TextField::create('TextField', 'TextField'), EmailField::create('EmailField', 'EmailField'), PasswordField::create('PasswordField', 'PasswordField'), TextareaField::create('TextareaField', 'TextareaField'), FileField::create('FileField', 'FileField'), CheckboxField::create('CheckboxField', 'CheckboxField'), DropdownField::create('DropdownField', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->setEmptyString(''), CheckboxsetField::create('CheckboxsetField', 'CheckboxsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), OptionsetField::create('OptionsetField', 'OptionsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), HeaderField::create('FieldGroupHeader', 'Field Groups', 3), FieldGroup::create(TextField::create('FieldGroupTextField', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField1', 'TextField')->addExtraClass('small-6 columns')), FieldGroup::create(TextField::create('FieldGroupTextField2', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField3', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField4', 'TextField')->addExtraClass('small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField5', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField6', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField7', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField8', 'TextField')->addExtraClass('small-3 columns')), FieldGroup::create(TextField::create('FieldGroupTextField9', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField10', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField11', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField12', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField13', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField14', 'TextField')->addExtraClass('large-2 small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField15', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField16', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField17', 'TextField')->addExtraClass('small-2 columns')), FieldGroup::create(DropdownField::create('DropdownField2', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString(''), DropdownField::create('DropdownField3', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString('')), HeaderField::create('SwitchFieldsHeader', 'Switch Fields', 3), FoundationSwitchField::create('SwitchField', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large-12'), FoundationSwitchField::create('SwitchField2', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large round'));
$actions = new FieldList(new FormAction('submitFoundationForm', 'Submit'));
// set all to required to see the validation message appearance
$required = array();
if ($dataFields = $fields->dataFields()) {
foreach ($dataFields as $child) {
$required[] = $child->getName();
}
}
$validator = new RequiredFields($required);
$form = new FoundationForm($this, __FUNCTION__, $fields, $actions, $validator);
// load submitted data, and clear them from session
if ($data = Session::get('FoundationForm' . $this->ID)) {
$form->loadDataFrom($data);
Session::clear('FoundationForm' . $this->ID);
}
return $form;
}
开发者ID:helpfulrobot,项目名称:rywa-silverstripe-foundation-forms,代码行数:20,代码来源:FoundationFormPage.php
示例17: getFormField
public function getFormField()
{
$field = FileField::create($this->Name, $this->Title);
// filter out '' since this would be a regex problem on JS end
$field->getValidator()->setAllowedExtensions(array_filter(Config::inst()->get('File', 'allowed_extensions')));
if ($this->getSetting('Folder')) {
$folder = Folder::get()->byId($this->getSetting('Folder'));
if ($folder) {
$field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename));
}
}
if ($this->Required) {
// Required validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
}
return $field;
}
开发者ID:sekjal,项目名称:silverstripe-userforms,代码行数:20,代码来源:EditableFileField.php
示例18: __construct
function __construct($controller, $name)
{
$f = new FieldList();
$f->push(BootstrapTextField::create('Name', "Full name"));
$f->push(BootstrapEmailField::create('Email', "Email (will not be published)"));
$f->push(BootstrapEmailField::create('ContactNumber', 'Contact number (will not be published)'));
$f->push(CustomCountryDropdownField::create('Country')->setEmptyString('--please select--'));
$f->push(BootstrapTextField::create('Town'));
$f->push(BootstrapTextField::create('Latitude'));
$f->push(BootstrapTextField::create('Longitude'));
$f->push(FileField::create('Image'));
$f->push(BootstrapTextareaField::create('Description')->setRightTitle("<div id='charLeft'><span>200</span></div>"));
$actions = new FieldList($btn = new FormAction('doSubmit', 'Submit'));
$btn->addExtraClass("btn");
$aRequiredFields = array();
$aRequiredFields[] = "Name";
$aRequiredFields[] = "Email";
$aRequiredFields[] = "Description";
$requiredFields = new RequiredFields();
parent::__construct($controller, $name, $f, $actions, $requiredFields);
$this->addExtraClass('form-horizontal ' . get_class());
//$this->loadValidationScripts($this, $aRequiredFields);
}
开发者ID:helpfulrobot,项目名称:chitosystems-silverstripe-distributor-map,代码行数:23,代码来源:DistributorForm.php
示例19: __construct
public function __construct()
{
parent::__construct('import');
$this->setMethod('post');
$this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
$commandHidden = new HiddenField('command');
$this->addElement($commandHidden->setValue('upload-lp'));
$fileField = new FileField('file');
$fileField->setLabel(OW::getLanguage()->text('admin', 'lang_file'));
$this->addElement($fileField);
$submit = new Submit('submit');
$this->addElement($submit->setValue(OW::getLanguage()->text('admin', 'clone_form_lbl_submit')));
}
开发者ID:hardikamutech,项目名称:hammu,代码行数:13,代码来源:languages.php
示例20: testFileFieldGetDataNotWorking
/**
* @expectedException \RuntimeException
*
*/
public function testFileFieldGetDataNotWorking()
{
$f = new FileField();
$f->getData();
}
开发者ID:Temsi,项目名称:php-hypermedia-api,代码行数:9,代码来源:FileFieldTest.php
注:本文中的FileField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论