本文整理汇总了PHP中FieldList::unshift方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::unshift方法的具体用法?PHP FieldList::unshift怎么用?PHP FieldList::unshift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldList
的用法示例。
在下文中一共展示了FieldList::unshift方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($controller, $name)
{
$this->controller = $controller;
$userSubmissionHolder = $this->controller->data();
$editableFormFields = $userSubmissionHolder->Fields()->filter(array('EnableOnSearchForm' => true));
$fields = new FieldList();
foreach ($editableFormFields as $editableFormField) {
$field = $this->getFormFieldFromEditableFormField($editableFormField);
if ($field) {
$fields->push($field);
}
}
$willCreateKeywordsField = $userSubmissionHolder->Fields()->find('UseInKeywordSearch', true);
if ($willCreateKeywordsField) {
$fields->unshift($field = TextField::create('Keywords', 'Keywords'));
}
$actions = new FieldList($submitButton = FormAction::create('doSearch', 'Search')->setUseButtonTag($this->config()->submit_use_button_tag)->addExtraClass($this->config()->submit_classes));
$validator = UserSubmissionSearchFormValidator::create();
$validator->fields = $fields;
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->disableSecurityToken();
// Retain search text and selections for pagination pages
// (as pagination doesn't trigger the httpSubmission function)
$this->loadDataFrom($controller->getRequest()->requestVars());
// note(Jake): Probably the perfect way to extend the form. Leaving commented until real use case arises.
//$this->extend('updateForm');
}
示例2: setRequireExistingPassword
/**
* Set if the existing password should be required
*
* @param bool $show Flag to show or hide this field
* @return $this
*/
public function setRequireExistingPassword($show)
{
// Don't modify if already added / removed
if ((bool) $show === $this->requireExistingPassword) {
return $this;
}
$this->requireExistingPassword = $show;
$name = $this->getName();
$currentName = "{$name}[_CurrentPassword]";
if ($show) {
$confirmField = PasswordField::create($currentName, _t('Member.CURRENT_PASSWORD', 'Current Password'));
$this->children->unshift($confirmField);
} else {
$this->children->removeByName($currentName, true);
}
return $this;
}
示例3: Actions
/**
* @return FieldList
*/
public function Actions()
{
if (!$this->getCanAddInline()) {
return new FieldList();
}
if ($this->actions) {
return $this->actions;
}
// Setup default actions
$this->actions = new FieldList();
$this->actions->unshift($inlineAddButton = FormAction::create('AddInlineRecord', 'Add')->addExtraClass('multirecordfield-addinlinebutton js-multirecordfield-add-inline')->setAttribute('autocomplete', 'off')->setUseButtonTag(true));
$this->actions->unshift($classField = DropdownField::create('ClassName', ' ')->addExtraClass('multirecordfield-classname js-multirecordfield-classname')->setAttribute('autocomplete', 'off')->setEmptyString('(Select section type to create)'));
$inlineAddButton->addExtraClass('ss-ui-action-constructive ss-ui-button');
$inlineAddButton->setAttribute('data-icon', 'add');
// NOTE(Jake): add 'updateActions' here if needed later.
// Update FormAction fields with button classes
// todo(Jake): Find a better location for applying this
$this->applyButtonClasses($this->actions);
return $this->actions;
}
示例4: __construct
/**
* @param Controller $controller
* @param String $name
* @param GroupedProduct $product
*/
public function __construct($controller, $name, GroupedProduct $product)
{
$fields = new FieldList();
// add quantity etc fields
// TODO: These should probably be cleaned up and put in composite fields or something
foreach ($product->ChildProducts() as $child) {
if (!$child->hasExtension('GroupedCartFormChildHooks')) {
user_error('Child Products must have GroupedCartFormChildHooks applied.');
}
$vars = $child->hasMethod('Variations') ? $child->Variations() : null;
if ($vars && $vars->count() > 0) {
foreach ($child->getVariationFields() as $f) {
$fields->push($f);
}
}
$fields->push($child->getQuantityField());
}
$actions = new FieldList(array(FormAction::create('addtocart', _t('GroupedCartForm.ADD', 'Add to Cart'))));
// integrate with wishlist module
if (class_exists('WishList')) {
$actions->unshift(FormAction::create('addtowishlist', _t('GroupedCartForm.ADDTOWISHLIST', 'Add to Wish List')));
}
parent::__construct($controller, $name, $fields, $actions);
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-groupedproducts,代码行数:29,代码来源:GroupedCartForm.php
示例5: unshift
/**
* Add a new child field to the beginning of the set.
*
* @param FormField
*/
public function unshift(FormField $field)
{
$this->children->unshift($field);
}
示例6: updateCMSFields
function updateCMSFields(FieldList $fields)
{
$fields->removeByName('Published');
$fields->unshift(CheckboxField::create('Published', _t('CMSPublishableDataExtension.PUBLISHED', 'Published')));
return $fields;
}
开发者ID:helpfulrobot,项目名称:arillo-silverstripe-cleanutilities,代码行数:6,代码来源:CMSPublishableDataExtension.php
示例7: testPushFieldToBeginningOfSet
/**
* Test pushing a field to the beginning of a set.
*
* This tests {@link FieldList->unshift()}.
*/
public function testPushFieldToBeginningOfSet()
{
$fields = new FieldList();
/* A field named Country is added to the set */
$fields->unshift(new TextField('Country'));
/* We only have 1 field in the set */
$this->assertEquals(1, $fields->Count());
/* Another field called Email is added to the set */
$fields->unshift(new EmailField('Email'));
/* There are now 2 fields in the set */
$this->assertEquals(2, $fields->Count());
/* The most recently added field is at the beginning of the set */
$this->assertEquals('Email', $fields->First()->getName());
// Test that pushing a composite field without a name onto the set works
$fields->unshift(new CompositeField(new TextField('Test1'), new TextField('Test2')));
$this->assertEquals(3, $fields->Count());
}
示例8: getCMSFields
public function getCMSFields()
{
$fields = new FieldList($this->getCMSFieldsForVideo());
$fields->unshift(new TextField('Title', 'Title/Label (optional)'));
return $fields;
}
示例9: addLocaleIndicatorMessage
/**
* Adds a UI message to indicate whether you're editing in the default locale or not
*
* @param FieldList $fields
* @return $this
*/
protected function addLocaleIndicatorMessage(FieldList $fields)
{
if (Fluent::config()->disable_current_locale_message) {
return $this;
}
// If the field is already present, don't add it a second time
if ($fields->fieldByName('CurrentLocaleMessage')) {
return $this;
}
$localeNames = Fluent::locale_names();
$isDefaultLocale = Fluent::default_locale() === Fluent::current_locale();
$messageClass = $isDefaultLocale ? 'good' : 'notice';
$message = $isDefaultLocale ? _t('Fluent.DefaultLocale', 'This is the default locale') : _t('Fluent.DefaultLocaleIs', 'The default locale is') . ' ' . $localeNames[Fluent::default_locale()];
$fields->unshift(LiteralField::create('CurrentLocaleMessage', sprintf('<p class="message %s">' . _t('Fluent.EditingIn', 'Please note: You are editing in') . ' %s. %s.</p>', $messageClass, $localeNames[Fluent::current_locale()], $message)));
return $this;
}