ProductVariation::getCMSFields PHP Method

getCMSFields() public method

public getCMSFields ( )
    public function getCMSFields()
    {
        $fields = FieldList::create(TextField::create('InternalItemID', _t('Product.Code', 'Product Code')), TextField::create('Price', _t('Product.db_BasePrice', 'Price')));
        //add attributes dropdowns
        $attributes = $this->Product()->VariationAttributeTypes();
        if ($attributes->exists()) {
            foreach ($attributes as $attribute) {
                if ($field = $attribute->getDropDownField()) {
                    if ($value = $this->AttributeValues()->find('TypeID', $attribute->ID)) {
                        $field->setValue($value->ID);
                    }
                    $fields->push($field);
                } else {
                    $fields->push(LiteralField::create('novalues' . $attribute->Name, '<p class="message warning">' . _t('ProductVariation.NoAttributeValuesMessage', '{attribute} has no values to choose from. You can create them in the "Products" &#62; "Product Attribute Type" section of the CMS.', 'Warning that will be shown if an attribute doesn\'t have any values', array('attribute' => $attribute->Name)) . '</p>'));
                }
                //TODO: allow setting custom values here, rather than visiting the products section
            }
        } else {
            $fields->push(LiteralField::create('savefirst', '<p class="message warning">' . _t('ProductVariation.MustSaveFirstMessage', "You can choose variation attributes after saving for the first time, if they exist.") . '</p>'));
        }
        $fields->push(UploadField::create('Image', _t('Product.Image', 'Product Image')));
        //physical measurement units
        $fieldSubstitutes = array('LengthUnit' => Product::config()->length_unit);
        //physical measurements
        $fields->push(TextField::create('Weight', _t('Product.WeightWithUnit', 'Weight ({WeightUnit})', '', array('WeightUnit' => Product::config()->weight_unit)), '', 12));
        $fields->push(TextField::create('Height', _t('Product.HeightWithUnit', 'Height ({LengthUnit})', '', $fieldSubstitutes), '', 12));
        $fields->push(TextField::create('Width', _t('Product.WidthWithUnit', 'Width ({LengthUnit})', '', $fieldSubstitutes), '', 12));
        $fields->push(TextField::create('Depth', _t('Product.DepthWithUnit', 'Depth ({LengthUnit})', '', $fieldSubstitutes), '', 12));
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }