Amend the data before displaying.

@param string $fieldname Field name
@param mixed  $value Value to be amended
@param string $model Optional model to be used
@return mixed
183801
public function display(string $fieldname, $value, string $model = null)
    {
        $value = $value === true ? 'true' : 'false';

        return $value;
    }
108405
private function setMutated(string $name, $value)
    {
        $setter = $this->getMutator($name, self::MUTATOR_SETTER);

        if (!empty($setter)) {
            try {
                $this->fields[$name] = call_user_func($setter, $value);
            } catch (\Exception $e) {
                //Exceptional situation, we are choosing to keep original field value
            }
        } else {
            $this->fields[$name] = $value;
        }
    }
705288
public function set($name, $value = UNDEFINED)
    {
        if (is_array($name)) {
            foreach ($name as $key => $val) {
                $this->set($key, $val);
            }

            return $this;
        }
        if ($name === false || $name === null) {
            return $this->reset();
        }

        // Verify if such a field exists
        if ($this->strict_fields && !$this->hasElement($name)) {
            throw $this->exception('No such field', 'Logic')
            ->addMoreInfo('name', $name);
        }

        if ($value !== UNDEFINED
            && (
                is_object($value)
                || is_object($this->data[$name])
                || is_array($value)
                || is_array($this->data[$name])
                || (string) $value != (string) $this->data[$name] // this is not nice..
                || $value !== $this->data[$name] // considers case where value = false and data[$name] = null
                || !isset($this->data[$name]) // considers case where data[$name] is not initialized at all
                                              //    (for example in model using array controller)
            )
        ) {
            $this->data[$name] = $value;
            $this->setDirty($name);
        }

        return $this;
    }
270465
public function fillFieldWithValue(string $fieldName, $value, ?string $containerName = null): void
    {
        $newContainerName = (!$containerName) ? $containerName : sprintf($this::NEW_FIELD_TITLE_PATTERN, EzFieldElement::getFieldInternalNameByName($containerName));
        $fieldElement = $this->getField($fieldName, $newContainerName);
        $fieldElement->setValue($value);
    }
1221367
public function setFieldValue($name, $value)
    {
        foreach ($this->fields as $key => $fields) {
            if (isset($fields[$name])) {
                $this->fields[$key][$name]->setValue($value);
            }
        }
        return $this;
    }
972932
public function withFieldAnnotation($fieldName, $name, $value)
    {
        $copy = clone $this;

        $copy->annotations = $this->annotations->update(
            $fieldName,
            function (ArrayMap $fieldAnnotations) use ($name, $value) {
                return $fieldAnnotations->insert($name, $value);
            },
            ArrayMap::zero()
        );

        return $copy;
    }
256780
protected function _getUpdateFieldValue($fieldName, $field)
    {
        $fieldValue = null;
        if ($field instanceof Field) {
            $fieldValue = $field->getRawValue();
        } elseif (isset($field->value)) {
            $fieldValue = $field->value;
        }

        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        //Check if this field value is null AND it can be null according if not returning default value
        if ((null === $fieldValue)) {
            if ($this->_canFieldBeNull($fieldName)) {
                return 'null';
            } elseif ($fieldValue = $this->_getFieldDefaultValue($fieldName)) {
                return $database->quote($fieldValue);
            }
        }

        return $database->quote($fieldValue);
    }
414276
public function RemoveFormValue($FieldName) {
      $this->FormValues();
      
      if (!is_array($FieldName))
         $FieldName = array($FieldName);
      
      foreach ($FieldName as $Field)
         unset($this->_FormValues[$Field]);
   }
909053
public function modifyValue($value) : Field
    {
        if (is_string($value)) {
            $this->attributes['value'] = explode(',', $value);
        }

        if ($value instanceof \Closure) {
            $this->attributes['value'] = $value($this->attributes);
        }

        if (is_null($value)) {
            $this->attributes['value'] = [];
        }

        return $this;
    }
969656
private function canonicalizeFieldValue($fieldname, $fieldvalue)
    {
        switch ($fieldname) {
            case 'email':
                return strtolower(trim($fieldvalue));

            case 'username':
                return strtolower(preg_replace('/[^a-zA-Z0-9_\\-]/', '', $fieldvalue));

            default:
                return trim($fieldvalue);
        }
    }
837459
public function increment(string $field, $value)
    {
        $this->update();
        $this->mongoDbUpdate['$inc'][$field] = $value;

        return $this;
    }
124220
public function alter($name, $prop, $value) {
        foreach ($this->_fields as &$field) {
            if ($field->name === $name) {
                $field->{$prop} = $value;
            }
        }
    }
209702
public function setModel(\atk4\data\Model $model, $fields = null)
    {
        parent::setModel($model);

        if ($fields === false) {
            return $model;
        }

        if ($fields === null) {
            $fields = $this->getModelFields($model);
        }

        // prepare array of fields - check if fields are editable or read_only/disabled
        $add_fields = [];
        foreach ($fields as $field) {
            $f = $model->getElement($field);

            if ($f->isEditable()) {
                $add_fields[] = [$f->short_name];
            } elseif ($f->isVisible()) {
                $add_fields[] = [$f->short_name, ['readonly'=>true]];
            }
        }

        if (is_array($add_fields)) {
            foreach ($add_fields as $field) {
                call_user_func_array([$this, 'addField'], $field);
            }
        } else {
            throw new Exception(['Incorrect value for $fields', 'fields' => $add_fields]);
        }

        return $model;
    }
1203324
public function fillFieldWithValue(string $fieldName, array $value): void
    {
        $fieldElement = $this->getField($fieldName);
        $fieldElement->setValue($value);
    }
1042268
protected function _setFieldValue($field, $value)
    {
        // ignore setting versioning fields
        if (static::isVersioned()) {
            if (array_key_exists($field, static::$versioningFields)) {
                return false;
            }
        }

        if (!static::fieldExists($field)) {
            return false;
        }
        $fieldOptions = static::$_classFields[get_called_class()][$field];

        // no overriding autoincrements
        if ($fieldOptions['autoincrement']) {
            return false;
        }

        // pre-process value
        $forceDirty = false;
        switch ($fieldOptions['type']) {
            case 'clob':
            case 'string':
            {
                $value = $this->_setStringValue($fieldOptions, $value);
                break;
            }

            case 'boolean':
            {
                $value = $this->_setBooleanValue($value);
                break;
            }

            case 'decimal':
            {
                $value = $this->_setDecimalValue($value);
                break;
            }

            case 'int':
            case 'uint':
            case 'integer':
            {
                $value = $this->_setIntegerValue($fieldOptions, $value);
                break;
            }

            case 'timestamp':
            {
                $value = $this->_setTimestampValue($value);
                break;
            }

            case 'date':
            {
                $value = $this->_setDateValue($value);
                break;
            }

            // these types are converted to strings from another PHP type on save
            case 'serialized':
            {
                $this->_convertedValues[$field] = $value;
                $value = $this->_setSerializedValue($value);
                break;
            }
            case 'enum':
            {
                $value = $this->_setEnumValue($fieldOptions, $value);
                break;
            }
            case 'set':
            case 'list':
            {
                $value = $this->_setListValue($fieldOptions, $value);
                $this->_convertedValues[$field] = $value;
                $forceDirty = true;
                break;
            }
        }

        if ($forceDirty || (empty($this->_record[$field]) && isset($value)) || ($this->_record[$field] !== $value)) {
            $columnName = static::_cn($field);
            if (isset($this->_record[$columnName])) {
                $this->_originalValues[$field] = $this->_record[$columnName];
            }
            $this->_record[$columnName] = $value;
            $this->_isDirty = true;

            // unset invalidated relationships
            if (!empty($fieldOptions['relationships']) && static::isRelational()) {
                foreach ($fieldOptions['relationships'] as $relationship => $isCached) {
                    if ($isCached) {
                        unset($this->_relatedObjects[$relationship]);
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }
964212
public function setField($field, $value = '')
    {
        $condition = !empty($this->options['where']) ? $this->options['where'] : [];

        if (empty($condition)) {
            // 没有条件不做任何更新
            throw new Exception('no data to update');
        }

        if (is_array($field)) {
            $data = $field;
        } else {
            $data[$field] = $value;
        }

        return $this->update($data);
    }
124433
protected function prepareFieldValue(array &$field_value)
    {
        $this->setItemImages($field_value, 'field_value', $this->image);
        $this->setItemTranslation($field_value, 'field_value', $this->translation_entity);

        if (!empty($field_value['images'])) {
            foreach ($field_value['images'] as &$file) {
                $this->setItemTranslation($file, 'file', $this->translation_entity);
            }
        }
    }