2017 © Pedro PelĆ”ez
 

silverstripe-module silverstripe-i18nenum

Translatable Enum fieldtype for Silverstripe.

image

unisolutions/silverstripe-i18nenum

Translatable Enum fieldtype for Silverstripe.

  • Wednesday, December 23, 2015
  • by uniun
  • Repository
  • 2 Watchers
  • 5 Stars
  • 637 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 3 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

silverstripe-i18nenum

Translatable Enum fieldtype, (*1)

Maintainer Contact

Elvinas Liutkevičius, (*2)

, (*3)

Requirements

SilverStripe 3, (*4)

Documentation

Simply install the module using the standard method., (*5)

Now you can create datafield with translatable enum Field:, (*6)

class MyDataObject extends DataObject {
    public static $db = array(
        'DbField' => "i18nEnum('default, other', 'default')",
    );
}

To get translated Enum value in GridField, you need to return the value in this way:, (*7)

class MyDataObject extends DataObject {
    ...
    public function DbField() {
        return i18nEnum::getTranslatedValue($this->className, __FUNCTION__, $this->{__FUNCTION__});
    }
}

By default translation namespace will be your DataObject class name and the entity will be constructed like this: "db_{DbField}_{enum value}". So your translation file should look like this:, (*8)

lang:
  MyDataObject:
    db_DbField_default: 'Default'
    db_DbField_other: 'Other'

Known issues

  • GridField filtering in GridFieldFilterHeader won't work as expected - it still constructs the search filter using enum values only.

The Versions

23/12 2015

dev-master

9999999-dev

Translatable Enum fieldtype for Silverstripe.

  Sources   Download

The Requires

 

silverstripe i18n translatable enum