当前位置: 首页>>代码示例>>PHP>>正文


PHP FormField::create方法代码示例

本文整理汇总了PHP中FormField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::create方法的具体用法?PHP FormField::create怎么用?PHP FormField::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormField的用法示例。


在下文中一共展示了FormField::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Field

 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     if ($this->includeDefaultJS) {
         Requirements::javascriptTemplate(FRAMEWORK_DIR . '/javascript/InlineFormAction.js', array('ID' => $this->id()));
     }
     return DBField::create_field('HTMLText', FormField::create('input', array('name' => sprintf('action_%s', $this->getName()), 'value' => $this->title, 'id' => $this->ID(), 'class' => sprintf('action%s', $this->extraClass))));
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:11,代码来源:InlineFormAction.php

示例2: testErrors

 public function testErrors()
 {
     $form = Form::create()->add(Primitive::ternary('flag')->setFalseValue('0')->setTrueValue('1'))->add(Primitive::integer('old')->required())->addRule('someRule', Expression::between(FormField::create('old'), '18', '35'));
     //empty import
     $form->import(array())->checkRules();
     //checking
     $expectingErrors = array('old' => Form::MISSING, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertEquals(Form::MISSING, $form->getError('old'));
     $this->assertEquals(Form::WRONG, $form->getError('someRule'));
     $this->assertTrue($form->hasError('old'));
     $this->assertFalse($form->hasError('flag'));
     //drop errors
     $form->dropAllErrors();
     $this->assertEquals(array(), $form->getErrors());
     //import wrong data
     $form->clean()->importMore(array('flag' => '3', 'old' => '17'))->checkRules();
     //checking
     $expectingErrors = array('flag' => Form::WRONG, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertTrue($form->hasError('someRule'));
     //marking good and custom check errors
     $form->markGood('someRule')->markCustom('flag', 3);
     $this->assertEquals(array('flag' => 3), $form->getErrors());
     $this->assertFalse($form->hasError('someRule'));
     $this->assertNull($form->getError('someRule'));
     $this->assertEquals(3, $form->getError('flag'));
     //import right data
     $form->dropAllErrors()->clean()->importMore(array('flag' => '1', 'old' => '35'));
     //checking
     $this->assertEquals(array(), $form->getErrors());
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:32,代码来源:FormTest.class.php

示例3: AJAXLinkHiddenField

 /**
  * Used for storing the quantity update link for ajax use.
  */
 public function AJAXLinkHiddenField()
 {
     if ($quantitylink = $this->item->setquantityLink()) {
         $attributes = array('type' => 'hidden', 'class' => 'ajaxQuantityField_qtylink', 'name' => $this->MainID() . '_Quantity_SetQuantityLink', 'value' => $quantitylink);
         $formfield = FormField::create('hack');
         return $formfield->createTag('input', $attributes);
     }
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:11,代码来源:ShopQuantityField.php

示例4: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     //include JS to handling showing and hiding of bottom "action" tabs
     Requirements::javascript(DMS_DIR . '/javascript/DMSDocumentCMSFields.js');
     Requirements::css(DMS_DIR . '/css/DMSDocumentCMSFields.css');
     $fields = new FieldList();
     //don't use the automatic scaffolding, it is slow and unnecessary here
     $extraTasks = '';
     //additional text to inject into the list of tasks at the bottom of a DMSDocument CMSfield
     $extraFields = FormField::create('Empty');
     //get list of shortcode page relations
     $relationFinder = new ShortCodeRelationFinder();
     $relationList = $relationFinder->getList($this->ID);
     $fieldsTop = $this->getFieldsForFile($relationList->count());
     $fields->add($fieldsTop);
     $fields->add(new TextField('Title', 'Title'));
     $fields->add(new TextareaField('Description', 'Description'));
     $fields->add(new UploadField('CustomIcon', 'Icon'));
     //create upload field to replace document
     $uploadField = new DMSUploadField('ReplaceFile', 'Replace file');
     $uploadField->setConfig('allowedMaxFileNumber', 1);
     $uploadField->setConfig('downloadTemplateName', 'ss-dmsuploadfield-downloadtemplate');
     $uploadField->setRecord($this);
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(30), new GridFieldDetailForm());
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => 'Title', 'ClassName' => 'Page Type', 'ID' => 'Page ID'))->setFieldFormatting(array('Title' => sprintf('<a class=\\"cms-panel-link\\" href=\\"%s/$ID\\">$Title</a>', singleton('CMSPageEditController')->Link('show'))));
     $pagesGrid = GridField::create('Pages', _t('DMSDocument.RelatedPages', 'Related Pages'), $this->Pages(), $gridFieldConfig);
     $referencesGrid = GridField::create('References', _t('DMSDocument.RelatedReferences', 'Related References'), $relationList, $gridFieldConfig);
     if (DMSDocument_versions::$enable_versions) {
         $versionsGridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(30));
         $versionsGridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(Config::inst()->get('DMSDocument_versions', 'display_fields'))->setFieldCasting(array('LastChanged' => "Datetime->Ago"))->setFieldFormatting(array('FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\' href=\'$Link\'>$FilenameWithoutID</a>'));
         $versionsGrid = GridField::create('Versions', _t('DMSDocument.Versions', 'Versions'), $this->getVersions(), $versionsGridFieldConfig);
         $extraTasks .= '<li class="ss-ui-button" data-panel="find-versions">Versions</li>';
         //$extraFields = $versionsGrid->addExtraClass('find-versions');
     }
     $fields->add(new LiteralField('BottomTaskSelection', '<div id="Actions" class="field actions"><label class="left">Actions</label><ul>' . '<li class="ss-ui-button" data-panel="embargo">Embargo</li>' . '<li class="ss-ui-button" data-panel="expiry">Expiry</li>' . '<li class="ss-ui-button" data-panel="replace">Replace</li>' . '<li class="ss-ui-button" data-panel="find-usage">Usage</li>' . '<li class="ss-ui-button" data-panel="find-references">References</li>' . $extraTasks . '</ul></div>'));
     $embargoValue = 'None';
     if ($this->EmbargoedIndefinitely) {
         $embargoValue = 'Indefinitely';
     } elseif ($this->EmbargoedUntilPublished) {
         $embargoValue = 'Published';
     } elseif (!empty($this->EmbargoedUntilDate)) {
         $embargoValue = 'Date';
     }
     $embargo = new OptionsetField('Embargo', 'Embargo', array('None' => 'None', 'Published' => 'Hide document until page is published', 'Indefinitely' => 'Hide document indefinitely', 'Date' => 'Hide until set date'), $embargoValue);
     $embargoDatetime = DatetimeField::create('EmbargoedUntilDate', '');
     $embargoDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy');
     $expiryValue = 'None';
     if (!empty($this->ExpireAtDate)) {
         $expiryValue = 'Date';
     }
     $expiry = new OptionsetField('Expiry', 'Expiry', array('None' => 'None', 'Date' => 'Set document to expire on'), $expiryValue);
     $expiryDatetime = DatetimeField::create('ExpireAtDate', '');
     $expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy');
     // This adds all the actions details into a group.
     // Embargo, History, etc to go in here
     // These are toggled on and off via the Actions Buttons above
     // exit('hit');
     $actionsPanel = FieldGroup::create(FieldGroup::create($embargo, $embargoDatetime)->addExtraClass('embargo'), FieldGroup::create($expiry, $expiryDatetime)->addExtraClass('expiry'), FieldGroup::create($uploadField)->addExtraClass('replace'), FieldGroup::create($pagesGrid)->addExtraClass('find-usage'), FieldGroup::create($referencesGrid)->addExtraClass('find-references'), FieldGroup::create($versionsGrid)->addExtraClass('find-versions'));
     $actionsPanel->setName("ActionsPanel");
     $actionsPanel->addExtraClass("ActionsPanel");
     $fields->push($actionsPanel);
     // $fields->add(FieldGroup::create(
     // 		FieldGroup::create(
     // 			$embargo,
     // 			$embargoDatetime
     // 		)->addExtraClass('embargo'),
     // 		FieldGroup::create(
     // 			$expiry,
     // 			$expiryDatetime
     // 		)->addExtraClass('expiry'),
     // 		$uploadField->addExtraClass('replace'),
     // 		$pagesGrid->addExtraClass('find-usage'),
     // 		$referencesGrid->addExtraClass('find-references'),
     // 		$extraFields
     // )->setName("ActionsPanel")->addExtraClass('dmsupload ss-uploadfield'));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:nadeeth,项目名称:silverstripe-dms,代码行数:81,代码来源:DMSDocument.php


注:本文中的FormField::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。