Uses the $extraFields property to return an array with extra field names or definitions.
@param ActiveRecord $model
@param string $context one of: 'grid', 'detail', 'form', 'searchForm'
@return array
767784
public function getExtraFields($model, $context = null)
    {
        if (is_array($this->extraFields)) {
            return $this->extraFields;
        } elseif (is_callable($this->extraFields)) {
            return call_user_func($this->extraFields, $this, $context, $model);
        }
        return static::getDefaultFields($model, true);
    }
635111
public function getMainField($model)
    {
        // describe the model
        $desc = $this->desc($model);

        // search by fields for primary key
        foreach (array_keys($desc[$model]) as $field) {
            return $field;
        }
    }
883482
protected function replaceFieldValuesWhenOnResource(Model $model, array $only = []): array
    {
        $resource = $this->resolveResource($model);
        $fields   = $this->resourceFields($resource);

        $row = [];
        foreach ($fields as $field) {
            if (!$this->isExportableField($field)) {
                continue;
            }

            if (\in_array($field->attribute, $only, true)) {
                $row[$field->attribute] = $field->value;
            } elseif (\in_array($field->name, $only, true)) {
                // When no field could be found by their attribute name, it's most likely a computed field.
                $row[$field->name] = $field->value;
            }
        }

        // Add fields that were requested by ->only(), but are not registered as fields in the Nova resource.
        foreach (array_diff($only, array_keys($row)) as $attribute) {
            if ($model->{$attribute}) {
                $row[$attribute] = $model->{$attribute};
            } else {
                $row[$attribute] = '';
            }
        }

        return $row;
    }
49245
public function validate($model, $fields = [])
    {
        $context = $this->_context;

        $context->messages = [];

        if (!$rules = $model->rules()) {
            return;
        }

        $context->model = $model;

        if (is_string($fields)) {
            $fields = (array)preg_split('#[\s,]+#', $fields, -1, PREG_SPLIT_NO_EMPTY);
        }

        $templates = null;
        foreach ($fields ?: $model->getChangedFields() as $field) {
            if (!isset($rules[$field])) {
                continue;
            }
            $context->field = $field;

            foreach ((array)$rules[$field] as $k => $v) {
                if (is_int($k)) {
                    $name = $v;
                    $parameters = null;
                } else {
                    $name = $k;
                    $parameters = $v;
                }

                $value = $this->_validate($model->$field, $name, $parameters);
                if ($value === null) {
                    $templates = $this->_templates ?: $this->_loadTemplates();
                    $template = isset($templates[$name]) ? $templates[$name] : $templates['default'];
                    $this->appendMessage(new Message($template, $context->model, $context->field, $parameters));
                } else {
                    $model->$field = $value;
                }
            }
        }

        if ($context->messages) {
            throw new ValidateFailedException('validate failed: ' . json_encode($context->messages));
        }
    }
910719
function(record, extraNames) {
      var fieldNames = record.getFields().map(function (field) {
        return field.getName();
      });

      if (extraNames) {
        fieldNames = fieldNames.concat(extraNames);
      }
      return fieldNames;
    }
1348538
def _get_model_fields(self, field_names, declared_fields, extra_kwargs):
        
        model = getattr(self.Meta, 'model')
        model_fields = {}

        for field_name in field_names:
            if field_name in declared_fields:
                # If the field is declared on the serializer
                field = declared_fields[field_name]
                source = field.source or field_name
            else:
                try:
                    source = extra_kwargs[field_name]['source']
                except KeyError:
                    source = field_name

            if '.' in source or source == '*':
                # Model fields will always have a simple source mapping,
                # they can't be nested attribute lookups.
                continue

            try:
                field = model._meta.get_field(source)
                if isinstance(field, DjangoModelField):
                    model_fields[source] = field
            except FieldDoesNotExist:
                pass

        return model_fields
837414
public function fieldsOf($model)
    {
        $method = 'fields_get';

        $result = $this->call($model, $method, []);


        return $this->makeResponse($result);
    }
1068974
public function createFormBuilder($model, $form = 'default', $context = [], $options=[])
    {
        $fb = $this->formFactory->createBuilder(FormType::class, $model, $options);

        $this->populateFormBuilder($fb, $model, $form, $context);
        return $fb;
    }
1038405
def _get_fields_for_model(model):
    
    fields = []
    for name in model._sa_class_manager:
        prop = getattr(model, name)
        if isinstance(prop.property, RelationshipProperty):
            for pk in prop.property.mapper.primary_key:
                fields.append('{0}.{1}'.format(name, pk.name))
        else:
            fields.append(name)
    return tuple(fields)
599200
private function buildSelectorForExcerpt($locale, &$additionalFields)
    {
        $excerptStructure = $this->structureManager->getStructure('excerpt');
        $extension = $this->extensionManager->getExtension('', 'excerpt');

        foreach ($excerptStructure->getProperties(true) as $property) {
            $additionalFields[$locale][] = [
                'extension' => $extension,
                'target' => 'excerpt',
                'property' => $property->getName(),
                'name' => $property->getName(),
            ];
        }
    }
256709
public function getDetailAttributes($model, $fields)
    {
        if (!$model instanceof ActiveRecord) {
            return $model->attributes();
        }
        /** @var ActiveRecord $model */
        $formats = $model->attributeFormats();
        $keys    = self::getModelKeys($model);
        list($behaviorAttributes, $blameableAttributes) = self::getModelBehaviorAttributes($model);
        $attributes = $model->attributes();
        $versionAttribute = $model->optimisticLock();
        $result = [];
        foreach ($fields as $key => $field) {
            if (is_array($field)) {
                $result[$key] = $field;
                continue;
            } elseif (!is_string($field) && is_callable($field)) {
                $result[$key] = call_user_func($field, $model);
                continue;
            }

            if (in_array($field, $attributes)) {
                if (in_array($field, $keys) || in_array($field, $blameableAttributes) || $field === $versionAttribute) {
                    continue;
                }
                $result[$field] = [
                    'attribute' => $field,
                    'format' => $formats[$field],
                ];
                continue;
            }

            $relation = $model->getRelation($field);
            if (!$relation->multiple) {
                // validate foreign keys only for hasOne relations
                foreach ($relation->link as $left => $right) {
                    if (in_array($left, $blameableAttributes)) {
                        continue;
                    }
                }
            }

            if (!Yii::$app->user->can($relation->modelClass . '.read')) {
                continue;
            }
            $result[$field] = [
                'attribute' => $field,
                'format'    => 'crudLink',
                'visible'   => true,
                'label'     => $model instanceof ActiveRecord ? $model->getRelationLabel($relation, $field) : null,
            ];
        }
        return $result;
    }
10019
public function getExtraFields()
    {
        if ($this->_extraFields === null) {
            $extraFields = [];
            foreach ($this->getConfig() as $pointer => $fields) {
                if (is_array($fields)) {
                    foreach ($fields as $field) {
                        if (isset($field['extraField']) && $field['extraField']) {
                            if (!array_key_exists($field['name'], $extraFields)) {
                                $extraFields[] = $field['name'];
                            }
                        }
                    }
                }
            }
            $this->_extraFields = $extraFields;
        }

        return $this->_extraFields;
    }
1131274
public function getMultiCount($collection, $column, array $values, array $extra = [])
    {
        $builder = $this->select($collection);
        $builder->where($builder->expr()->in("e.{$column}", $values));

        $this->queryExtraConditions($extra, $builder);

        return $builder->getQuery()->getSingleScalarResult();
    }
291494
public function search(string $model, array $fields) : ?array
  {
    $response = array();
    foreach($fields as $param => $value) {
      $check = $model::where($param, $value)->first();

      if ($check != null) {
        $response = array_merge($response, array($param => "The $param has already been taken."));
      }
    }

    return $response;
  }
323819
public function getDeepRelations(Model $model, $extended = true) {
        $contain = array_keys($model->belongsTo);
        $contain = array_merge($contain, array_keys($model->hasAndBelongsToMany));

        if ($extended) {
            foreach (array($model->hasOne, $model->hasMany) as $assocs) {
                foreach ($assocs as $alias => $assoc) {
                    $contain[$alias] = array_keys($model->{$alias}->belongsTo);
                }
            }
        }

        return $contain;
    }
1057145
public function getFormFields($model, $multiple = false)
    {
        $formFields[] = [
            'table' => [
                'attribute' => 'table',
                'formMethod' => 'dropDownList',
                'arguments' => [
                    'items' => call_user_func(['nineinchnick\audit\models\AuditForm', 'getAuditTables'])
                ],
            ]
        ];
        foreach (Yii::$app->controller->module->filters as $propety => $params) {
            $formFields[] = static::addFormField($model, $propety, $params);
        }
        return $formFields;
    }
951841
public function extra(array $data, $prefix = '')
    {
        $rules = $this->nested;

        // Drill down to prefix level
        if (!empty($prefix)) {
            $parts = explode('.', trim($prefix, '.'));
            foreach ($parts as $part) {
                $rules = isset($rules[$part]) ? $rules[$part] : [];
            }
        }

        // Check if the form cannot have extra fields.
        if (isset($rules[''])) {
            $rule = $this->items[''];
            if (isset($rule['type']) && $rule['type'] !== '_root') {
                return [];
            }
        }

        return $this->extraArray($data, $rules, $prefix);
    }