本文整理汇总了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))));
}
示例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());
}
示例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);
}
}
示例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;
}