@param Asker $asker
@param       $modelName
@param       $fieldName
@param Field $field

@return string|void

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
509693
public static function askNotNullAddition(Asker $asker, $modelName, $fieldName, $field)
    {
        $msg = 'You are trying to add a non-nullable field "%s" to %s without a default; '.PHP_EOL.
            'we can\'t do that (the database needs something to populate existing rows).'.PHP_EOL.
            'Please select a fix:'.PHP_EOL;

        $choices = [
            'Provide a one-off default now (will be set on all existing rows)',
            'Quit, and let me add a default in model file',
        ];

        foreach ($choices as $index => $choice) {
            $msg .= sprintf("\t%s. %s".PHP_EOL, $index + 1, $choice);
        }

        $msg .= 'Select an option: ';

        $selected = (int) $asker->ask(new Question(sprintf($msg, $fieldName, $modelName)));

        if (2 == $selected) {
            return;
        }

        return self::getDefault($asker);
    }
1145829
public function addRequiredField($fieldName, $message = null)
    {
        return $this->setRule($fieldName, RequiredRule::create($message));
    }
1054074
public function add($fieldName)
    {
        if (strpos($fieldName, '[') === false && strpos($fieldName, ']') === false && in_array('*', $this->fieldList)) {
            $this->fieldList = array_diff($this->fieldList, ['*']);
        }

        $this->fieldList[] = $fieldName;
    }
387786
protected function _fieldName(FormHelper $helper, $name)
    {
        $prefix = $helper->prefix();
        if (!empty($prefix) && strpos($name, $prefix) !== 0) {
            $name = "{$prefix}{$name}";
        }

        return $name;
    }
1136612
public function getModelDefinitionByFieldName($fieldName)
    {
        foreach ($this->fieldMappings as $mapping) {
            if (in_array($fieldName, $mapping->getFields())) {
                return $mapping;
            }
        }

        throw new \InvalidArgumentException(sprintf('%s does not exists in %s', $fieldName, $this->name));
    }
666427
public function getDefSettingValue($asker, $asked)
    {
        $settings = $this->getSetting($asker);

        return isset($settings[$asked]) ? $settings[$asked] : null;
    }
540699
public function fieldIsRequired($fieldName)
    {
        $required = false;

        $constraints = $this->getConstraints($fieldName);
        if ($constraints) {
            foreach ($constraints as $constraint) {
                if ($constraint instanceof Constraint_required) {
                    $required = true;
                    break;
                }
            }
        }

        return $required || parent::fieldIsRequired($fieldName);
    }
667083
public function fieldIsRequired($fieldName)
    {
        if ($rules = $this->getRulesForFieldName($fieldName)) {
            
            foreach ($rules as $rule) {
                
                if ($rule instanceof RequiredRule) {
                    return true;
                }
                
            }
            
        }
        
        return parent::fieldIsRequired($fieldName);
    }
1346796
protected function fieldNameError(FormField $field, $functionName)
    {
        if ($this->form) {
            $errorSuffix = sprintf(
                " in your '%s' form called '%s'",
                get_class($this->form),
                $this->form->getName()
            );
        } else {
            $errorSuffix = '';
        }

        user_error(
            sprintf(
                "%s() I noticed that a field called '%s' appears twice%s",
                $functionName,
                $field->getName(),
                $errorSuffix
            ),
            E_USER_ERROR
        );
    }
170336
public function setFieldValue($fieldName, $value)
    {
        if ($this->hasField($fieldName) == false) {
            throw new SolrMappingException(sprintf('Field %s does not exist', $fieldName));
        }

        $field = $this->getField($fieldName);
        $field->value = $value;
    }
920089
public function isAllowedField($modelClass, $fieldName, $privilege = null)
    {
        return $this->isAllowed($this->fieldResourceGenerator($modelClass, $fieldName), $privilege);
    }
703146
public function addField($name, $decorator = null, $field = null)
    {
        if (!is_string($name)) {
            throw new Exception(['Format for addField now require first argument to be name']);
        }

        if (!$this->form->model) {
            $this->form->model = new \atk4\ui\misc\ProxyModel();
        }

        if (is_string($field)) {
            $field = ['type' => $field];
        }

        if ($name) {
            $existingField = $this->form->model->hasElement($name);
        }

        try {
            if (!$existingField) {
                // Add missing field
                if ($field) {
                    $field = $this->form->model->addField($name, $field);
                } else {
                    $field = $this->form->model->addField($name);
                }
            } elseif (is_array($field)) {
                // Add properties to existing field
                $existingField->setDefaults($field);
                $field = $existingField;
            } elseif (is_object($field)) {
                throw new Exception(['Duplicate field', 'name' => $name]);
            } else {
                $field = $existingField;
            }

            if (is_string($decorator)) {
                $decorator = $this->form->decoratorFactory($field, ['caption' => $decorator]);
            } elseif (is_array($decorator)) {
                $decorator = $this->form->decoratorFactory($field, $decorator);
            } elseif (!$decorator) {
                $decorator = $this->form->decoratorFactory($field);
            } elseif (is_object($decorator)) {
                if (!$decorator instanceof \atk4\ui\FormField\Generic) {
                    throw new Exception(['Field decorator must descend from \atk4\ui\FormField\Generic', 'decorator' => $decorator]);
                }
                $decorator->field = $field;
                $decorator->form = $this->form;
            } else {
                throw new Exception(['Value of $decorator argument is incorrect', 'decorator' => $decorator]);
            }
        } catch (\Throwable $e) {
            throw new Exception(['Unable to add form field', 'name' => $name, 'decorator' => $decorator, 'field' => $field], null, $e);
        }

        return $this->_addField($decorator, $field);
    }
464160
protected function handleFieldWithSubquery(string $fieldName, BoolOperator $boolOperator): Node
    {
        $this->stream->nextIf(Token::T_SUBQUERY_START);
        $subquery = $this->handleSubquery($boolOperator);
        $this->stream->skipUntil(Token::T_FIELD_END);

        if ($subquery instanceof Subquery) {
            $m = $this->getModifiers();
            return new Field($fieldName, $subquery, $boolOperator, $m['use_boost'], $m['boost']);
        }

        if (empty($subquery)) {
            return $this->createWord($fieldName, $boolOperator);
        }

        $m = $this->getModifiers();
        return new Field($fieldName, $subquery, $boolOperator, $m['use_boost'], $m['boost']);
    }
281159
public function & GetField ($fieldName = '') {
		$result = NULL;
		if (isset($this->fields[$fieldName]))
			$result = & $this->fields[$fieldName];
		return $result;
	}
718092
protected function _allowEmpty(Model $model, $field, $value) {
        if (isset($this->_validations[$field]['required'])) {
            $rule = $this->_validations[$field]['required'];
            $required = isset($rule['rule'][1]) ? $rule['rule'][1] : true;

            if ($this->_isEmpty($value)) {
                if ($rule['allowEmpty']) {
                    return true;

                } else if ($required) {
                    return false;
                }
            }
        }

        return false;
    }
1159365
function &fieldNamed($fieldName)
    {
        $return = NULL;
        if (isset($this->_fields[$fieldName])) {
            $return =& $this->_fields[$fieldName];
        }

        return $return;
    }
665549
protected function assertField($field)
    {
        if (!$this->hasField($field)) {
            throw new ModelException(sprintf('Unknown field, field "%s" not found in model "%s"', $field, $this->entity));
        }
    }