Version: current

# Class StringField

An abstract base class for the string field types (i.e. Varchar and Text)

  Object
  ViewableData implements IteratorAggregate
  DBField
  StringField

### Direct known subclasses

`Text`, `Varchar`

### Indirect known subclasses

`DBLocale`, `HTMLText`, `HTMLVarchar`, `ShopCountry`

Abstract
Package: sapphire\model
Author: Pete Bacon Darwin
Located at sapphire/core/model/fieldtypes/StringField.php

## Methods summary

`public` | # `__construct( mixed $name = null, mixed $options = array() )` Construct a string type field with a set of optional parameters Construct a string type field with a set of optional parameters #### Parameters $name $name string The name of the field $options $options array An array of options e.g. array('nullifyEmpty'=>false). See `StringField::setOptions()` for information on the available options #### Overrides `DBField::__construct`
`public unknown_type` | # `setOptions( array $options = array() )` Update the optional parameters for this field. Update the optional parameters for this field. #### Parameters $options $options array of options The options allowed are: "nullifyEmpty" This is a boolean flag. True (the default) means that empty strings are automatically converted to nulls to be stored in the database. Set it to false to ensure that nulls and empty strings are kept intact in the database. #### Returns `unknown_type` unknown_type
`public` | # `setNullifyEmpty( mixed $value )` Set whether this field stores empty strings rather than converting them to null Set whether this field stores empty strings rather than converting them to null #### Parameters $value $value boolean True if empty strings are to be converted to null
`public boolean` | # `getNullifyEmpty( )` Get whether this field stores empty strings rather than converting them to null Get whether this field stores empty strings rather than converting them to null #### Returns `boolean` True if empty strings are to be converted to null
`public boolean` | # `hasValue( )` (non-PHPdoc) (non-PHPdoc) #### Returns `boolean` boolean #### See core/model/fieldtypes/DBField#hasValue() #### Overrides `DBField::hasValue`
`public string` | # `prepValueForDB( mixed $value )` (non-PHPdoc) (non-PHPdoc) #### Parameters $value $value mixed The value to check #### Returns `string` The encoded value #### See core/model/fieldtypes/DBField#prepValueForDB($value) #### Overrides `DBField::prepValueForDB`
`public` | # `Lower( )` Return another DBField object with this value in lowercase. Return another DBField object with this value in lowercase.
`public` | # `Upper( )` Return another DBField object with this value in uppercase. Return another DBField object with this value in uppercase.

### Methods inherited from DBField

`ATT()`, `HTML()`, `HTMLATT()`, `JS()`, `LowerCase()`, `RAW()`, `RAWURLATT()`, `URLATT()`, `UpperCase()`, `XML()`, `addToQuery()`, `create()`, `debug()`, `defaultSearchFilter()`, `exists()`, `forTemplate()`, `getName()`, `getValue()`, `nullValue()`, `requireField()`, `saveInto()`, `scaffoldFormField()`, `scaffoldSearchField()`, `setName()`, `setTable()`, `setValue()`, `writeToManipulation()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `defineMethods()`, `escapeTypeForField()`, `getField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `hasField()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`, `setField()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `createMethod()`, `create_from_string()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`protected boolean` | $nullifyEmpty | #

### Properties inherited from DBField

`$arrayValue`, `$defaultVal`, `$default_search_filter_class`, `$escape_type`, `$name`, `$tableName`, `$value`

### Properties inherited from ViewableData

`$casting`, `$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -