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


PHP ReadonlyField::setEmptyString方法代码示例

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


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

示例1: getCMSFields

 function getCMSFields()
 {
     $product = $this->Product();
     $fields = new FieldSet(new TabSet('Root', new Tab('Main', new NumericField('Price'), new CheckboxField('AllowPurchase', _t("ProductVariation.ALLOWPURCHASE", 'Allow Purchase ?')), new TextField('InternalItemID', _t("ProductVariation.INTERNALITEMID", 'Internal Item ID')), new TextField('Description', _t("ProductVariation.DESCRIPTION", "Description (optional)")), new ImageField('Image'))));
     $types = $product->VariationAttributes();
     if ($this->ID) {
         $purchased = $this->getPurchasedTotal();
         $values = $this->AttributeValues();
         foreach ($types as $type) {
             $field = $type->getDropDownField();
             if ($field) {
                 $value = $values->find('TypeID', $type->ID);
                 if ($value) {
                     $field->setValue($value->ID);
                     if ($purchased) {
                         $field = $field->performReadonlyTransformation();
                         $field->setName("Type{$type->ID}");
                     }
                 } else {
                     if ($purchased) {
                         $field = new ReadonlyField("Type{$type->ID}", $type->Name, _t("ProductVariation.ALREADYPURCHASED", 'NOT SET (you can not select a value now because it has already been purchased).'));
                     } else {
                         $field->setEmptyString('');
                     }
                 }
             } else {
                 $field = new ReadonlyField("Type{$type->ID}", $type->Name, _t("ProductVariation.NOVALUESTOSELECT", 'No values to select'));
             }
             $fields->addFieldToTab('Root.Attributes', $field);
         }
         $fields->addFieldToTab('Root.Orders', new ComplexTableField($this, 'OrderItems', 'ProductVariation_OrderItem', array('Order.ID' => '#', 'Order.Created' => 'When', 'Order.Member.Name' => 'Member', 'Quantity' => 'Quantity', 'Total' => 'Total'), new FieldSet(), "\"BuyableID\" = '{$this->ID}'", "\"Created\" DESC"));
     } else {
         foreach ($types as $type) {
             $field = $type->getDropDownField();
             $fields->addFieldToTab('Root.Attributes', $field);
         }
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:riddler7,项目名称:silverstripe-product-variations,代码行数:40,代码来源:ProductVariation.php

示例2: getCMSFields

 /**
  * Standard SS method
  * @return FieldSet
  */
 function getCMSFields()
 {
     //backup in case there are no products.
     if (Product::get()->count() == 0) {
         return parent::getCMSFields();
     }
     $product = $this->Product();
     $productField = new DropdownField('ProductID', _t("ProductVariation.PRODUCT", 'Product'), Product::get()->map('ID', 'Title')->toArray());
     $productField->setEmptyString('(Select one)');
     $fields = new FieldList(new TabSet('Root', new Tab('Main', $productField, $fullNameLinkField = ReadOnlyField::create('FullNameLink', _t("ProductVariation.FULLNAME", 'Full Name'), "<a href=\"" . $this->Link() . "\">" . $this->FullName . "</a>"), new NumericField('Price', _t("ProductVariation.PRICE", 'Price')), new CheckboxField('AllowPurchase', _t("ProductVariation.ALLOWPURCHASE", 'Allow Purchase ?'))), new Tab('Details', new TextField('InternalItemID', _t("ProductVariation.INTERNALITEMID", 'Internal Item ID')), new TextField('Description', _t("ProductVariation.DESCRIPTION", "Description (optional)"))), new Tab('Image', new Product_ProductImageUploadField('Image'))));
     $fullNameLinkField->dontEscape = true;
     if ($this->EcomConfig()->ProductsHaveWeight) {
         $fields->addFieldToTab('Root.Details', new NumericField('Weight', _t('ProductVariation.WEIGHT', 'Weight')));
     }
     if ($this->EcomConfig()->ProductsHaveModelNames) {
         $fields->addFieldToTab('Root.Details', new TextField('Model', _t('ProductVariation.MODEL', 'Model')));
     }
     if ($this->EcomConfig()->ProductsHaveQuantifiers) {
         $fields->addFieldToTab('Root.Details', new TextField('Quantifier', _t('ProductVariation.QUANTIFIER', 'Quantifier (e.g. per kilo, per month, per dozen, each)')));
     }
     $fields->addFieldToTab('Root.Details', new ReadOnlyField('FullSiteTreeSort', _t('Product.FULLSITETREESORT', 'Full sort index')));
     if ($product) {
         $types = $product->VariationAttributes();
         if ($this->ID) {
             $hasBeenSold = $this->HasBeenSold();
             $values = $this->AttributeValues();
             foreach ($types as $type) {
                 $field = $type->getDropDownField();
                 if ($field) {
                     $value = $values->find('TypeID', $type->ID);
                     if ($value) {
                         $field->setValue($value->ID);
                         if ($hasBeenSold) {
                             $field = $field->performReadonlyTransformation();
                             $field->setName("Type{$type->ID}");
                         }
                     } else {
                         if ($hasBeenSold) {
                             $field = new ReadonlyField("Type{$type->ID}", $type->Name, _t("ProductVariation.ALREADYPURCHASED", 'NOT SET (you can not select a value now because it has already been purchased).'));
                         } else {
                             $field->setEmptyString('');
                         }
                     }
                 } else {
                     $field = new ReadonlyField("Type{$type->ID}", $type->Name, _t("ProductVariation.NOVALUESTOSELECT", 'No values to select'));
                 }
                 $fields->addFieldToTab('Root.Attributes', $field);
             }
         } else {
             foreach ($types as $type) {
                 $field = $type->getDropDownField();
                 $fields->addFieldToTab('Root.Attributes', $field);
             }
         }
     }
     $fields->addFieldToTab('Root.Main', new LiteralField('AddToCartLink', "<p class=\"message good\"><a href=\"" . $this->AddLink() . "\">" . _t("Product.ADD_TO_CART", "add to cart") . "</a></p>"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce_product_variation,代码行数:63,代码来源:ProductVariation.php


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