@param mixed       $value
@param string      $field
@param string|null $subField
@param string|null $block

@throws \Bolt\Exception\StorageException

@return FieldValue|bool
180557
public function getHydratedValue($value, $field, $subField = null, $block = null)
    {
        $fields = $this->getFields();

        foreach ($fields as $key => $mapping) {
            if ($key !== $field) {
                continue;
            }
            $fieldType = $this->fieldManager->get($mapping['fieldtype'], $mapping);

            if ($subField !== null) {
                $subMapping = isset($mapping['data']['fields'][$subField]) ? $mapping['data']['fields'][$subField] : null;
                if (!isset($subMapping['fieldtype'])) {
                    continue;
                }
                $fieldType = $this->fieldManager->get($subMapping['fieldtype'], $subMapping);
                $field = $subField;
            }

            if ($block !== null) {
                $subMapping = $mapping['data']['fields'][$block]['fields'][$subField];
                $fieldType = $this->fieldManager->get($subMapping['fieldtype'], $subMapping);
                $field = $subField;
            }

            $tmpentity = new FieldValue();
            $fieldType->hydrate([$field => $value], $tmpentity);

            return $tmpentity[$field];
        }

        return false;
    }
969729
public function where($field, $value)
    {
        if (!isset($this->_expression[$field]) || !is_array($value) || !is_array($this->_expression[$field])) {
            $this->_expression[$field] = $value;
        } else {
            $this->_expression[$field] = array_merge_recursive($this->_expression[$field], $value);
        }

        return $this;
    }
730659
public function supports(ElementStructureValue $value, AbstractField $field)
    {
        foreach ($this->extractors as $extractor) {
            if ($extractor->supports($value, $field)) {
                return true;
            }
        }

        return false;
    }
163812
public function value($field)
    {
        if (is_array($field)) {
            $values = array();
            foreach ($field as $key => $value) {
                $values[$key] = $this->value($value);
            }

            return $values;
        }

        return ($this->submitted && isset($this->values[$field])) ? $this->values[$field] : null;
    }
618280
public function fillFieldWithValue( $field, $value = '' )
    {
        trigger_error(
            "fillFieldWithValue is deprecated since v6.3.0, use PlatformUI Context fillFieldWithValue instead",
            E_USER_DEPRECATED
        );
        $this->getSession()->getPage()->fillField( $field, $value );
    }
441876
protected function Sub( $value )
	{
		switch ( $value->GetValueCode() )
		{
			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var YearMonthDurationProxy $value
				 */
				// return new YearMonthDurationProxy( new YearMonthDurationValue( $this->_value->HighPartValue - (/* YearMonthDurationValue */ $value->getValue() )->HighPartValue ) );
				$clone = new YearMonthDurationValue( $this->_value->Value );
				$clone->Sub( /* YearMonthDurationValue */ $value->getValue() );
				return new YearMonthDurationProxy( $clone );

			default:
				throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:sub",
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $this->_value), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}
1203420
public function setField(string $field, $value)
    {
        if (isset($this->_record[$field]) && $this->_record[$field] === $value)
            return;

        $db = $this->getDB();
        $dao = $db->getDAO(static::class);
        $columns = $dao->getColumns();
        if (!isset($columns[$field]))
            throw new InvalidValueException("Field $field does not exist!");

        $pkey = $dao->getPrimaryKey();
        $coldef = $columns[$field];
        if (static::validate($coldef, $value))
        {
            $this->_record[$field] = $value;
            $this->_changed[$field] = true;

            if (isset($pkey[$field]))
                $this->_id[$field] = $value;

            // Synchronize value of local properties
            if (property_exists($this, $field))
                $this->$field = $value;
        }

        return $this;
    }
478841
public function fieldValueEquals($field, $value, TraversableElement $container = null)
    {
        $node = $this->fieldExists($field, $container);
        $actual = $node->getValue();
        $regex = '/^'.preg_quote($value, '/').'$/ui';

        $message = sprintf('The field "%s" value is "%s", but "%s" expected.', $field, $actual, $value);

        $this->assert((bool) preg_match($regex, $actual), $message);
    }
896655
public function serializeSaveField(Field $f, $value)
    {
        try {
            // use $f->serialize = [encode_callback, decode_callback]
            if (is_array($f->serialize) && isset($f->serialize[0]) && is_callable($t = $f->serialize[0])) {
                return $t($f, $value, $this);
            }

            // run persistence-specific serialization of field value
            return $this->_serializeSaveField($f, $value);
        } catch (\Exception $e) {
            throw new Exception(['Unable to serialize field value on save', 'field' => $f->name], null, $e);
        }
    }
1212158
function(value) {
	
	   // Render the subField
	   var subFieldEl = this.renderSubField(value);
	
		if(this.options.name) {
	   	subFieldEl.setFieldName(this.options.name+"["+this.subFields.length+"]");
		}
	
	   // Adds it to the local list
	   this.subFields.push(subFieldEl);
	   
	   return subFieldEl;
	}
1077992
public function typecastLoadField(Field $f, $value)
    {
        try {
            // use $f->typecast = [typecast_save_callback, typecast_load_callback]
            if (is_array($f->typecast) && isset($f->typecast[1]) && is_callable($t = $f->typecast[1])) {
                return $t($value, $f, $this);
            }

            // only string type fields can use empty string as legit value, for all
            // other field types empty value is the same as no-value, nothing or null
            if ($f->type && $f->type != 'string' && $value === '') {
                return;
            }

            // we respect null values
            if ($value === null) {
                return;
            }

            // run persistence-specific typecasting of field value
            return $this->_typecastLoadField($f, $value);
        } catch (\Exception $e) {
            throw new Exception(['Unable to typecast field value on load', 'field' => $f->name], null, $e);
        }
    }
291327
public function updateNonTranslatableField(
        Field $field,
        StorageFieldValue $value,
        $contentId
    ) {
        try {
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1202667
public function lt($field, $value)
    {
        if(!$value instanceof Part) {
            $value = $this->buildPart($value);
        }
        return new Expr\ComparisonExpression($field, $value, Expr\ComparisonExpression::LT);
    }
180870
public function addPostField($field, $value) {
        if (is_null($this->postData)) {
            $this->postData = array();
        }

        if (is_array($this->postData)) {
            $this->postData[$field] = (string) $value;
            return $this;
        } else {
            throw new LogicException('cannot set field for non array');
        }
    }
466938
public function iFillInSelect2Field($field, $value)
    {
        $page = $this->getSession()->getPage();

        $this->openField($page, $field);
        $this->selectValue($page, $field, $value, $this->timeout);
    }
445085
protected function parseValue(FieldBuilder $field, $value = null)
    {
        $parsedValue = null;

        // No data found, define a default by field type.
        switch ($field->getFieldType())
        {

            case 'checkbox':
            case 'checkboxes': // @todo remove this checkboxes statement for next major update.
            case 'radio':
            case 'select':
            case 'collection':

                $parsedValue = $this->parseArrayable($field, $value);
                break;

            case 'infinite':

                // Check for the registered fields and their default value if one.
                $parsedValue = $this->parseInfinite($field, $value);
                break;

            // Text
            // Textarea
            // Password
            // Media
            // Editor
            default:
                $parsedValue = $this->parseString($field, $value);
        }

        return $parsedValue;
    }
887745
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;
    }