Set field default value

@param $field
@param $value

@return $this
346017
public function fieldValue($field, $value)
    {
        if (!in_array($field, $this->supports)) {
            $this->supports[ ] = $field;
        }
        $this->values[ $field ] = $value;

        return $this;
    }
1274422
public function setNewValue($field, $value)
    {
        $this->assertValidField($field);

        $this->documentChangeSet[$field][1] = $value;
    }
1100411
public function setResult($field, $value)
    {
        if (!isset($this->results[$field])) {
            $this->results[$field] = $value;
        }

        return $this;
    }
1120626
protected function setAsFloat($field, $value)
    {
        if (in_array($field, $this->getColumns()) && (
                !array_key_exists($field, $this->object) ||
                $this->object[$field] !== $value
            )) {
            $this->dirtyFields[$field] = true;
        }
        $this->object[$field] = (float) $value;

        return $this;
    }
624703
public function addField(Field $field)
    {
        $this->fields->set($field->getColumn(), $field);
        
        return $this;
    }
1197625
public function set($field, $value = null)
    {
        if (func_num_args() == 1) {
            if (is_array($field)) {
                foreach ($field as $key => $value) {
                    if ($key === '0' || $key === 0) {
                        $this->set($value);
                    } else {
                        $this->set($key, $value);
                    }
                }

                return $this;
            } elseif ($field instanceof self) {
                $this->data = $field->data;
                //$this->id = $field->id;

                return $this;
            } else {
                $value = $field;
                $field = $this->title_field;
            }
        }

        $field = $this->normalizeFieldName($field);

        $f = $this->hasField($field);

        try {
            if ($f && $this->hook('normalize', [$f, $value]) !== false) {
                $value = $f->normalize($value);
            }
        } catch (Exception $e) {
            $e->addMoreInfo('field', $field);
            $e->addMoreInfo('value', $value);
            $e->addMoreInfo('f', $f);

            throw $e;
        }

        $default_value = $f ? $f->default : null;

        $original_value = array_key_exists($field, $this->dirty) ? $this->dirty[$field] :
            ((isset($f) && isset($f->default)) ? $f->default : null);

        $current_value = array_key_exists($field, $this->data) ? $this->data[$field] : $original_value;

        if (gettype($value) == gettype($current_value) && $value == $current_value) {
            // do nothing, value unchanged
            return $this;
        }

        if ($f) {
            // perform bunch of standard validation here. This can be re-factored in the future.
            if ($f->read_only) {
                throw new Exception([
                    'Attempting to change read-only field',
                    'field' => $field,
                    'model' => $this,
                ]);
            }

            // enum property support
            if (isset($f->enum) && $f->enum && $f->type != 'boolean') {
                if ($value === '') {
                    $value = null;
                }
                if ($value !== null && !in_array($value, $f->enum, true)) {
                    throw new Exception([
                        'This is not one of the allowed values for the field',
                        'field' => $field,
                        'model' => $this,
                        'value' => $value,
                        'enum'  => $f->enum,
                    ]);
                }
            }

            // values property support
            if ($f->values) {
                if ($value === '') {
                    $value = null;
                } elseif ($value === null) {
                    // all is good
                } elseif (!is_string($value) && !is_int($value)) {
                    throw new Exception([
                        'Field can be only one of pre-defined value, so only "string" and "int" keys are supported',
                        'field' => $field,
                        'model' => $this,
                        'value' => $value,
                        'values'=> $f->values,
                    ]);
                } elseif (!array_key_exists($value, $f->values)) {
                    throw new Exception([
                        'This is not one of the allowed values for the field',
                        'field'   => $field,
                        'model'   => $this,
                        'value'   => $value,
                        'values'  => $f->values,
                    ]);
                }
            }
        }

        if (array_key_exists($field, $this->dirty) && (
            gettype($this->dirty[$field]) == gettype($value) && $this->dirty[$field] == $value
        )) {
            unset($this->dirty[$field]);
        } elseif (!array_key_exists($field, $this->dirty)) {
            $this->dirty[$field] =
                array_key_exists($field, $this->data) ?
                $this->data[$field] : $default_value;
        }
        $this->data[$field] = $value;

        return $this;
    }
146662
public function whereEq($field, $value)
    {
        $bind_key = strpos($field, '.') !== false ? strtr($field, '.', '_') : $field;
        $normalizedField = preg_replace('#\w+#', '[\\0]', $field);
        $this->_conditions[] = "$normalizedField=:$bind_key";
        $this->_bind[$bind_key] = $value;

        return $this;
    }
347186
public function fillFieldWithValue($field, $value = '')
    {
        $fieldNode = $this->spin(
            function () use ($field) {
                $fieldNode = $this->getSession()->getPage()->findField($field);
                if ($fieldNode == null) {
                    throw new \Exception('Field not found');
                }

                return $fieldNode;
            }
        );

        $this->spin(
            function () use ($fieldNode, $field, $value) {
                // make sure any autofocus elements don't mis-behave when setting value
                $fieldNode->blur();
                usleep(10 * 1000);
                $fieldNode->focus();
                usleep(10 * 1000);

                // setting value on pre-filled inputs can cause issues, clearing before
                $fieldNode->setValue('');
                $fieldNode->setValue($value);

                // verication that the field was really filled in correctly
                $this->sleep();
                $check = $this->getSession()->getPage()->findField($field)->getValue();
                if ($check != $value) {
                    throw new \Exception('Failed to set the field value: ' . $check);
                }

                return true;
            }
        );
    }
848862
public function setValue($value): FieldTypeInterface
    {
        parent::setValue($value);

        if ($this->getValue()) {
            // The value is only set on the field when it fails
            // or when the option "flush" is set to "false".
            // If true, let's automatically add the "checked" attribute.
            $this->options['attributes']['checked'] = 'checked';
        }

        return $this;
    }
1284278
public function setFieldValue($fieldName, $value)
    {
        if (isset($this->originalValues[$fieldName])
            && $this->originalValues[$fieldName] === $value
        ) {
            # the given value is the same as the original value;
            # ignore any given value
            unset($this->givenValues[$fieldName]);
        } elseif (isset($this->originalValues[$fieldName])
            && $this->originalValues[$fieldName] !== $value
            && isset($this->defaults[$fieldName])
            && $this->defaults[$fieldName] === $value
        ) {
            # the given value is the same as a default value, but different from
            # the original value; change it
            $this->givenValues[$fieldName] = $value;
        } elseif (isset($this->defaults[$fieldName])
            && $this->defaults[$fieldName] === $value
        ) {
            # the given value is the same as the default value;
            # ignore any given value
            unset($this->givenValues[$fieldName]);
        } else {
            $this->givenValues[$fieldName] = $value;
        }
        return $this;
    }
1135345
public function setDefaultValue($value)
    {
        if (($value instanceof ValueGenerator) === false) {
            $value = new ValueGenerator($value);
        }

        if ($this->isValidParameterDefaultValue($value) !== true) {
            throw new InvalidArgumentException('Parameter default value is not valid.');
        }

        $this->defaultValue = $value;

        return $this;
    }
821427
public function setDefaultValue($value)
    {
        $value = $this->mmAttribute->valueToWidget($value);

        $this->set('value', $value);

    }
1320288
public function set_value($field = '', $default = '')
    {
        if (!isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) {
            return $default;
        }
        return $this->_field_data[$field]['postdata'];
    }
817963
public function setField(string $field, string $value)
        {
                return $this->_redis->hset($this->_key, $field, $value);
        }
422027
public function setFieldValue($name, $value)
    {
        foreach ($this->fieldsets as $fieldset) {
            if (isset($fieldset[$name])) {
                $fieldset[$name] = $value;
            }
        }
        return $this;
    }
1313097
protected function setData($field, $value)
    {
        if (property_exists($this, $field)) {
            $this->{$field} = $value;
        } else {
            throw new KeyInvalidException("Property \"{$field}\" does not exist on \"". get_class($this) ."\".");
        }

        return $this;
    }
466850
public function eq($field, $value) {
        if (is_array($value)) {
            $this->in($field, $value);

        } else if ($value === null) {
            $this->null($field);

        } else {
            $this->add($field, '=', $value);
        }

        return $this;
    }