本文整理汇总了PHP中HiddenField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP HiddenField::create方法的具体用法?PHP HiddenField::create怎么用?PHP HiddenField::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HiddenField
的用法示例。
在下文中一共展示了HiddenField::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($controller, $name, Order $order)
{
$this->order = $order;
$fields = FieldList::create(HiddenField::create('OrderID', '', $order->ID));
$actions = FieldList::create();
//payment
if (self::config()->allow_paying && $order->canPay()) {
$gateways = GatewayInfo::get_supported_gateways();
//remove manual gateways
foreach ($gateways as $gateway => $gatewayname) {
if (GatewayInfo::is_manual($gateway)) {
unset($gateways[$gateway]);
}
}
if (!empty($gateways)) {
$fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MAKEPAYMENT", "Make Payment")));
$outstandingfield = Currency::create();
$outstandingfield->setValue($order->TotalOutstanding());
$fields->push(LiteralField::create("Outstanding", sprintf(_t("OrderActionsForm.OUTSTANDING", "Outstanding: %s"), $outstandingfield->Nice())));
$fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PAYMENTMETHOD", "Payment Method"), $gateways, key($gateways)));
$actions->push(FormAction::create('dopayment', _t('OrderActionsForm.PAYORDER', 'Pay outstanding balance')));
}
}
//cancelling
if (self::config()->allow_cancelling && $order->canCancel()) {
$actions->push(FormAction::create('docancel', _t('OrderActionsForm.CANCELORDER', 'Cancel this order')));
}
parent::__construct($controller, $name, $fields, $actions);
$this->extend("updateForm", $order);
}
示例2: __construct
public function __construct($controller, $name = "VariationForm")
{
parent::__construct($controller, $name);
$product = $controller->data();
$farray = array();
$requiredfields = array();
$attributes = $product->VariationAttributeTypes();
foreach ($attributes as $attribute) {
$attributeDropdown = $attribute->getDropDownField(_t('VariationForm.ChooseAttribute', "Choose {attribute} …", '', array('attribute' => $attribute->Label)), $product->possibleValuesForAttributeType($attribute));
if ($attributeDropdown) {
$farray[] = $attributeDropdown;
$requiredfields[] = "ProductAttributes[{$attribute->ID}]";
}
}
$fields = FieldList::create($farray);
if (self::$include_json) {
$vararray = array();
$query = $query2 = new SQLQuery();
$query->setSelect('ID')->setFrom('ProductVariation')->addWhere(array('ProductID' => $product->ID));
if (!Product::config()->allow_zero_price) {
$query->addWhere('"Price" > 0');
}
foreach ($query->execute()->column('ID') as $variationID) {
$query2->setSelect('ProductAttributeValueID')->setFrom('ProductVariation_AttributeValues')->setWhere(array('ProductVariationID' => $variationID));
$vararray[$variationID] = $query2->execute()->keyedColumn();
}
$fields->push(HiddenField::create('VariationOptions', 'VariationOptions', json_encode($vararray)));
}
$fields->merge($this->Fields());
$this->setFields($fields);
$requiredfields[] = 'Quantity';
$this->setValidator(VariationFormValidator::create($requiredfields));
$this->extend('updateVariationForm');
}
示例3: FieldHolder
public function FieldHolder($properties = array())
{
Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css');
Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js');
if ($this->object && $this->object->ID) {
$properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
if (strlen($this->object->SourceURL)) {
$properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title'));
$properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width'));
$properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height'));
$properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', '');
$properties['Type'] = HiddenField::create($this->getName() . '[type]', '');
$properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', '');
$properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description'));
$properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class'));
foreach ($properties as $key => $field) {
if ($key == 'ObjectTitle') {
$key = 'Title';
} elseif ($key == 'ObjectDescription') {
$key = 'Description';
}
$field->setValue($this->object->{$key});
}
if ($this->object->ThumbURL) {
$properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />');
}
}
} else {
$properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
}
$field = parent::FieldHolder($properties);
return $field;
}
示例4: updateCMSFields
/**
* Updates the fields used in the CMS
* @see DataExtension::updateCMSFields()
*/
public function updateCMSFields(FieldList $fields)
{
Requirements::CSS('blogcategories/css/cms-blog-categories.css');
// Try to fetch categories from cache
$categories = $this->getAllBlogCategories();
if ($categories->count() >= 1) {
$cacheKey = md5($categories->sort('LastEdited', 'DESC')->First()->LastEdited);
$cache = SS_Cache::factory('BlogCategoriesList');
if (!($categoryList = $cache->load($cacheKey))) {
$categoryList = "<ul>";
foreach ($categories->column('Title') as $title) {
$categoryList .= "<li>" . Convert::raw2xml($title) . "</li>";
}
$categoryList .= "</ul>";
$cache->save($categoryList, $cacheKey);
}
} else {
$categoryList = "<ul><li>No categories exist. Categories can be added from the BlogTree or the BlogHolder page.</li></ul>";
}
//categories tab
$gridFieldConfig = GridFieldConfig_RelationEditor::create();
$fields->addFieldToTab('Root.Categories', GridField::create('BlogCategories', 'Blog Categories', $this->owner->BlogCategories(), $gridFieldConfig));
$fields->addFieldToTab('Root.Categories', ToggleCompositeField::create('ExistingCategories', 'View Existing Categories', array(new LiteralField("CategoryList", $categoryList)))->setHeadingLevel(4));
// Optionally default category to current holder
if (Config::inst()->get('BlogCategory', 'limit_to_holder')) {
$holder = $this->owner->Parent();
$gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form, $component) use($holder) {
$form->Fields()->push(HiddenField::create('ParentID', false, $holder->ID));
});
}
}
示例5: getCMSFields
/**
* Add the Meta tag CMS fields
*
* @since version 1.0.0
*
* @return object Return the current page fields
**/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('Main');
$fields->addFieldsToTab('Root.SEO', [HeaderField::create('Meta Tag'), DropdownField::create('Type', 'Tag type', $this->tagTypes()), TextField::create('Name'), TextField::create('Value'), HiddenField::create('PageID')]);
return $fields;
}
示例6: LinkForm
/**
* The LinkForm for the dialog window
*
* @return Form
**/
public function LinkForm()
{
$link = $this->getLinkObject();
$action = FormAction::create('doSaveLink', _t('Linkable.SAVE', 'Save'))->setUseButtonTag('true');
if (!$this->isFrontend) {
$action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
}
$link = null;
if ($linkID = (int) $this->request->getVar('LinkID')) {
$link = Link::get()->byID($linkID);
}
$link = $link ? $link : singleton('Link');
$link->setAllowedTypes($this->getAllowedTypes());
$fields = $link->getCMSFields();
$title = $link ? _t('Linkable.EDITLINK', 'Edit Link') : _t('Linkable.ADDLINK', 'Add Link');
$fields->insertBefore(HeaderField::create('LinkHeader', $title), _t('Linkable.TITLE', 'Title'));
$actions = FieldList::create($action);
$form = Form::create($this, 'LinkForm', $fields, $actions);
if ($link) {
$form->loadDataFrom($link);
$fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
}
$this->owner->extend('updateLinkForm', $form);
return $form;
}
示例7: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->insertBefore(new DropdownField('MemberID', 'Member', Member::get()->map('ID', "FirstName")), 'AttendingWholeEvent');
$siteConfig = SiteConfig::current_site_config();
$current = $siteConfig->getCurrentEventID();
if ($this->ParentID < 1) {
$event = Event::get()->byID($current);
} else {
$event = Event::get()->byID($this->ParentID);
}
$fields->insertAfter(HiddenField::create('ParentID', 'Event', $event->ID), 'ExtraDetail');
$fields->removeByName('PublicFieldsRaw');
$fields->removeByName('Sort');
if ($this->PlayerGames()->Count() > 0) {
$gridField = new GridField('PlayerGames', 'Games', $this->PlayerGames(), $config = GridFieldConfig_RelationEditor::create());
$gridField->setModelClass('PlayerGame');
$config->addComponent(new GridFieldOrderableRows());
$config->removeComponentsByType('GridFieldPaginator');
$config->removeComponentsByType('GridFieldPageCount');
$config->addComponent(new GridFieldDeleteAction(false));
$config->addComponent($export = new GridFieldExportButton('before'));
$export->setExportColumns(singleton("PlayerGame")->getExportFields());
$fields->addFieldToTab('Root.PlayerGames', $gridField);
}
return $fields;
}
示例8: getCMSFields
public function getCMSFields()
{
Requirements::css('widgetify/css/widgetify_cms.css');
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('widgetify/scripts/widgetify_page.js');
$fields = parent::getCMSFields();
$fields->push(HiddenField::create('WidgetifyContent', 'WidgetifyContent'));
$fields->push(HiddenField::create('ThisID', 'ThisID', $this->ID));
$tab = $fields->findOrMakeTab('Root.Main');
$tab->insertAfter(HeaderField::create('WidgetifyTitle', 'Widgetify Template', 3), 'Metadata');
if (!$this->WidgetifyTemplateID) {
$this->WidgetifyTemplateID = 0;
}
$templatesMap = DataList::create('WidgetifyTemplate')->map();
$tab->insertAfter(DropdownField::create('WidgetifyTemplateID', 'Select Template', $templatesMap)->setEmptyString('- Select -'), 'WidgetifyTitle');
$tab->insertAfter(CheckboxField::create('CSSFrontend', 'Apply template Stylesheet to front-end page'), 'WidgetifyTemplateID');
$tab->insertAfter(CheckboxField::create('JSFrontend', 'Apply template Javascript to front-end page'), 'CSSFrontend');
$tab->insertAfter(HeaderField::create('WidgetifyPreviewTitle', 'Widgetify Content', 3), 'JSFrontend');
$tab->insertAfter(LiteralField::create('WidgetifyPreview', '<div id="widgetifyPreview" class="widgetifyTemplate"></div>'), 'WidgetifyPreviewTitle');
$htmlField = HtmlEditorField::create('WidgetDynamicContent', false);
$editorFieldContents = '
<div id="WidgetDynamicContentHolder" class="WidgetDynamicContentHolder">
<p id="edit-widget-title">Edit content</p>' . $htmlField->forTemplate() . '
<p class="widget-edit-actions">
<a href="javascript:;" id="save-widget-content" class="ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary">Update</a>
<a href="javascript:;" id="cancel-widget-content" class="ss-ui-action-destructive ui-button ui-widget ui-state-default ui-button-text-icon-primary ui-corner-left ss-ui-button">Cancel</a>
</p>
</div>';
$tab->insertAfter(LiteralField::create('WidgetDynamicContentPlaceHolder', $editorFieldContents), 'WidgetifyPreview');
$fields->removeFieldFromTab('Root.Main', 'Content');
return $fields;
}
示例9: __construct
/**
* EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
* - The code has been cleaned up.
* - A form action for users who have lost their verification email has been added.
*
* We add fields in the constructor so the form is generated when instantiated.
*
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
* @param string $name The method on the controller that will return this form object.
* @param FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
* @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} of {@link FormAction} objects
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a the user is currently logged in, and if so, only a logout button will be rendered
*/
function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
{
$email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
$email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
$password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
$authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
$remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
$fields = FieldList::create($authentication_method_field);
$actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if (!$fields) {
$fields = FieldList::create($authentication_method_field, $email_field, $password_field);
if (Security::config()->remember_username) {
$email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
} else {
// Some browsers won't respect this attribute unless it's added to the form
$this->setAttribute('autocomplete', 'off');
$email_field->setAttribute('autocomplete', 'off');
}
}
if (!$actions) {
$actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
}
}
if (isset($_REQUEST['BackURL'])) {
$fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
}
// Reduce attack surface by enforcing POST requests
$this->setFormMethod('POST', true);
parent::__construct($controller, $name, $fields, $actions);
$this->setValidator(RequiredFields::create('Email', 'Password'));
}
开发者ID:jordanmkoncz,项目名称:silverstripe-memberemailverification,代码行数:46,代码来源:EmailVerificationLoginForm.php
示例10: FrontEndPostForm
/**
* A simple form for creating blog entries
*/
function FrontEndPostForm()
{
if ($this->owner->request->latestParam('ID')) {
$id = (int) $this->owner->request->latestParam('ID');
} else {
$id = 0;
}
$membername = Member::currentUser() ? Member::currentUser()->getName() : "";
// Set image upload
$uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image"));
$uploadfield->setCanAttachExisting(false);
$uploadfield->setCanPreviewFolder(false);
$uploadfield->setAllowedFileCategories('image');
$uploadfield->relationAutoSetting = false;
if (BlogFrontEnd::config()->allow_wysiwyg_editing) {
$content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content"));
} else {
$content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content"));
}
$form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title'));
$uploadfield->setForm($form);
if ($this->owner->Categories()->exists()) {
$fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map()));
}
if ($this->owner->Tags()->exists()) {
$fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map()));
}
if ($id && ($post = BlogPost::get()->byID($id))) {
$form->loadDataFrom($post);
}
$this->owner->extend("updateFrontEndPostForm", $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-blog-frontend,代码行数:36,代码来源:BlogFrontEndForm_BlogController.php
示例11: index
public function index()
{
$site = SiteConfig::current_site_config();
$order = $this->order;
// Setup the paypal gateway URL
if (Director::isDev()) {
$gateway_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$gateway_url = "https://www.paypal.com/cgi-bin/webscr";
}
$callback_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, "callback", $this->payment_gateway->ID);
$success_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete');
$error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error');
$back_url = Controller::join_links(Director::absoluteBaseURL(), Checkout_Controller::config()->url_segment, "finish");
$fields = new FieldList(HiddenField::create('business', null, $this->payment_gateway->BusinessID), HiddenField::create('item_name', null, $site->Title), HiddenField::create('cmd', null, "_cart"), HiddenField::create('paymentaction', null, "sale"), HiddenField::create('invoice', null, $order->OrderNumber), HiddenField::create('custom', null, $order->OrderNumber), HiddenField::create('upload', null, 1), HiddenField::create('discount_amount_cart', null, $order->DiscountAmount), HiddenField::create('amount', null, $order->Total), HiddenField::create('currency_code', null, $site->Currency()->GatewayCode), HiddenField::create('first_name', null, $order->FirstName), HiddenField::create('last_name', null, $order->Surname), HiddenField::create('address1', null, $order->Address1), HiddenField::create('address2', null, $order->Address2), HiddenField::create('city', null, $order->City), HiddenField::create('zip', null, $order->PostCode), HiddenField::create('country', null, $order->Country), HiddenField::create('email', null, $order->Email), HiddenField::create('return', null, $success_url), HiddenField::create('notify_url', null, $callback_url), HiddenField::create('cancel_return', null, $error_url));
$i = 1;
foreach ($order->Items() as $item) {
$fields->add(HiddenField::create('item_name_' . $i, null, $item->Title));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($item->Price + $item->Tax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, $item->Quantity));
$i++;
}
// Add shipping as an extra product
$fields->add(HiddenField::create('item_name_' . $i, null, _t("Commerce.Postage", "Postage")));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($order->PostageCost + $order->PostageTax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, "1"));
$actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('Submit', _t('Commerce.ConfirmPay', 'Confirm and Pay'))->addExtraClass('btn')->addExtraClass('btn-green'));
$form = Form::create($this, 'Form', $fields, $actions)->addExtraClass('forms')->setFormMethod('POST')->setFormAction($gateway_url);
$this->extend('updateForm', $form);
return array("Title" => _t('Commerce.CheckoutSummary', "Summary"), "MetaTitle" => _t('Commerce.CheckoutSummary', "Summary"), "Form" => $form);
}
示例12: PayForm
/**
* Return the payment form
*/
public function PayForm()
{
$request = $this->getRequest();
$response = Session::get('EwayResponse');
$months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
$years = range(date('y'), date('y') + 10);
//Note: years beginning with 0 might cause issues
$amount = $response->Payment->TotalAmount;
$amount = number_format($amount / 100, 2);
$currency = $response->Payment->CurrencyCode;
$fields = new FieldList(HiddenField::create('EWAY_ACCESSCODE', '', $response->AccessCode), TextField::create('PayAmount', 'Amount', $amount . ' ' . $currency)->setDisabled(true), $nameField = TextField::create('EWAY_CARDNAME', 'Card holder'), $numberField = TextField::create('EWAY_CARDNUMBER', 'Card Number'), $expMonthField = DropdownField::create('EWAY_CARDEXPIRYMONTH', 'Expiry Month', array_combine($months, $months)), $expYearField = DropdownField::create('EWAY_CARDEXPIRYYEAR', 'Expiry Year', array_combine($years, $years)), $cvnField = TextField::create('EWAY_CARDCVN', 'CVN Number'), HiddenField::create('FormActionURL', '', $response->FormActionURL));
//Test data
if (Director::isDev()) {
$nameField->setValue('Test User');
$numberField->setValue('4444333322221111');
$expMonthField->setValue('12');
$expYearField->setValue(date('y') + 1);
$cvnField->setValue('123');
}
$actions = new FieldList(FormAction::create('', 'Process'));
$form = new Form($this, 'PayForm', $fields, $actions);
$form->setFormAction($response->FormActionURL);
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript('payment-eway/javascript/eway-form.js');
$this->extend('updatePayForm', $form);
return $form;
}
示例13: AddNewListboxForm
public function AddNewListboxForm()
{
$action = FormAction::create('doSave', 'Save')->setUseButtonTag('true');
if (!$this->isFrontend) {
$action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
}
$model = $this->getModel();
$link = singleton($model);
$fields = $link->getCMSFields();
$title = $this->getDialogTitle() ? $this->getDialogTitle() : 'New Item';
$fields->insertBefore(HeaderField::create('AddNewHeader', $title), $fields->first()->getName());
$actions = FieldList::create($action);
$form = Form::create($this, 'AddNewListboxForm', $fields, $actions);
$fields->push(HiddenField::create('model', 'model', $model));
/*
if($link){
$form->loadDataFrom($link);
$fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
}
// Chris Bolt, fixed this
//$this->owner->extend('updateLinkForm', $form);
$this->extend('updateLinkForm', $form);
// End Chris Bolt
*/
return $form;
}
示例14: getHTMLFragments
public function getHTMLFragments($gridField)
{
$model = Injector::inst()->create($gridField->getModelClass());
$parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
if (!$model->canCreate()) {
return array();
}
$children = $this->getAllowedChildren($parent);
if (count($children) > 1) {
$pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
$pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
if (!$this->buttonName) {
$this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
}
} else {
$keys = array_keys($children);
$pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
if (!$this->buttonName) {
$this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
}
}
$state = $gridField->State->GridFieldSiteTreeAddNewButton;
$state->currentPageID = $parent->ID;
$state->pageType = $parent->defaultChild();
$addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
$addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
$forTemplate = new ArrayData(array());
$forTemplate->Fields = new ArrayList();
$forTemplate->Fields->push($pageTypes);
$forTemplate->Fields->push($addAction);
Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
}
示例15: __construct
public function __construct($controller, $name = "VariationForm")
{
parent::__construct($controller, $name);
$product = $controller->data();
$farray = array();
$requiredfields = array();
$attributes = $product->VariationAttributeTypes();
foreach ($attributes as $attribute) {
$farray[] = $attribute->getDropDownField(_t('VariationForm.CHOOSE_ATTRIBUTE', "Choose {attribute} …", '', array('attribute' => $attribute->Label)), $product->possibleValuesForAttributeType($attribute));
$requiredfields[] = "ProductAttributes[{$attribute->ID}]";
}
$fields = FieldList::create($farray);
if (self::$include_json) {
$vararray = array();
if ($vars = $product->Variations()) {
foreach ($vars as $var) {
$vararray[$var->ID] = $var->AttributeValues()->map('ID', 'ID')->toArray();
}
}
$fields->push(HiddenField::create('VariationOptions', 'VariationOptions', json_encode($vararray)));
}
$fields->merge($this->Fields());
$this->setFields($fields);
$requiredfields[] = 'Quantity';
$this->setValidator(VariationFormValidator::create($requiredfields));
$this->extend('updateVariationForm');
}