src/Forms/GridField/GridFieldDataColumns.php
protected function castValue($gridField, $fieldName, $value)
    {
        // If a fieldCasting is specified, we assume the result is safe
        if (array_key_exists($fieldName, $this->fieldCasting)) {
            $value = $gridField->getCastedValue($value, $this->fieldCasting[$fieldName]);
        } elseif (is_object($value)) {
            // If the value is an object, we do one of two things
            if (method_exists($value, 'Nice')) {
                // If it has a "Nice" method, call that & make sure the result is safe
                $value = Convert::raw2xml($value->Nice());
            } else {
                // Otherwise call forTemplate - the result of this should already be safe
                $value = $value->forTemplate();
            }
        } else {
            // Otherwise, just treat as a text string & make sure the result is safe
            $value = Convert::raw2xml($value);
        }

        return $value;
    }
protected function castValue($gridField, $fieldName, $value)
    {
        // If a fieldCasting is specified, we assume the result is safe
        if (array_key_exists($fieldName, $this->fieldCasting)) {
            $value = $gridField->getCastedValue($value, $this->fieldCasting[$fieldName]);
        } elseif (is_object($value)) {
            // If the value is an object, we do one of two things
            if (method_exists($value, 'Nice')) {
                // If it has a "Nice" method, call that & make sure the result is safe
                $value = Convert::raw2xml($value->Nice());
            } else {
                // Otherwise call forTemplate - the result of this should already be safe
                $value = $value->forTemplate();
            }
        } else {
            // Otherwise, just treat as a text string & make sure the result is safe
            $value = Convert::raw2xml($value);
        }

        return $value;
    }
protected function castValue ( $ gridField , $ fieldName , $ value ) { // If a fieldCasting is specified, we assume the result is safe if ( array_key_exists ( $ fieldName , $ this -> fieldCasting ) ) { $ value = $ gridField -> getCastedValue ( $ value , $ this -> fieldCasting [ $ fieldName ] ) ; } elseif ( is_object ( $ value ) ) { // If the value is an object, we do one of two things if ( method_exists ( $ value , 'Nice' ) ) { // If it has a "Nice" method, call that & make sure the result is safe $ value = Convert :: raw2xml ( $ value -> Nice ( ) ) ; } else { // Otherwise call forTemplate - the result of this should already be safe $ value = $ value -> forTemplate ( ) ; } } else { // Otherwise, just treat as a text string & make sure the result is safe $ value = Convert :: raw2xml ( $ value ) ; } return $ value ; }
Casts a field to a string which is safe to insert into HTML

@param GridField $gridField
@param string $fieldName
@param string $value
@return string
Casts a field to a string which is safe to insert into HTML