Adds customfields by fieldset name

@param Grid $grid
@param String $name
@return $this
348238
public function customfieldsByFieldset($grid, $name)
    {
        if (!extension_active('customfields')) {
            return;
        }
        $customfields = app('customfields')->get();
        $items        = [];
        $reserved     = [];
        foreach ($customfields as $classname => $fields) {
            if (get_class($grid->row) !== $classname) {
                continue;
            }
            foreach ($fields as $field) {
                if ($field->getFieldset() === $name) {
                    $reserved[] = $field->getName();
                    $items[]    = $field;
                }
            }
        }
        foreach ($items as $item) {
            $this->addCustomfield($grid, $item);
        }
        $query = \Antares\Customfields\Model\FieldView::query();
        if (!empty($reserved)) {
            $query->whereNotIn('name', $reserved);
        }

        $fields = $query->whereHas('fieldFieldset', function ($query) use ($name) {
                    $query->whereHas('fieldset', function ($subquery) use ($name) {
                        $subquery->where('name', $name);
                    });
                })->get();
        foreach ($fields as $field) {
            $this->addCustomfield($grid, $field);
        }
        return $this;
    }
38568
public function field($name = null, $flatten = false)
	{
		return $this->fieldset->field($name, $flatten);
	}
216730
public function addFields(array $fields)
    {
        foreach ($fields as $name => $attrs) {
            $this->addField($name, $attrs);
        }

        return $this;
    }
451935
public function setCustomActions($name, $data = null)
    {
        $actions = is_array($name) ? $name : [$name => $data];

        foreach ($actions as $key => $value) {
            $this->customActions[$key] = $value;
        }

        return $this;
    }
732385
public function adapt(Grid &$grid)
    {
        $this->grid   = $grid;
        $customfields = app('customfields')->get();
        if (empty($customfields)) {
            return;
        }
        foreach ($customfields as $classname => $customfield) {

            if (is_array($grid->row)) {
                continue;
            }
            if (get_class($grid->row) !== $classname) {
                continue;
            }
            if (!is_array($customfield)) {
                $customfield = [$customfield];
            }

            foreach ($customfield as $instance) {
                if (!is_object($instance)) {
                    continue;
                }

                $this->addToForm($instance);
            }
        }



        if (extension_active('customfields')) {
            $map   = config('antares/customfields::map', []);
            $types = [];
            foreach ($map as $type => $classnames) {
                foreach ($classnames as $classname) {

                    if (is_array($this->grid->row)) {
                        continue;
                    }
                    if (get_class($this->grid->row) !== $classname) {
                        continue;
                    }
                    array_push($types, $type);
                }
            }
            if (!empty($types)) {
                $this->getFields($types);
            }
        }
    }
1242781
protected function makeFormField($name, $config = [])
    {
        $label = $config['label'] ?? null;
        list($fieldName, $fieldContext) = $this->getFieldName($name);

        $field = new FormField($fieldName, $label);

        if ($fieldContext) {
            $field->context = $fieldContext;
        }

        $field->arrayName = $this->arrayName;
        $field->idPrefix = $this->getId();

        /*
         * Simple field type
         */
        if (is_string($config)) {
            if ($this->isFormWidget($config) !== false) {
                $field->displayAs('widget', ['widget' => $config]);
            }
            else {
                $field->displayAs($config);
            }
        }
        /*
         * Defined field type
         */
        else {
            $fieldType = $config['type'] ?? null;
            if (!is_string($fieldType) && $fieldType !== null) {
                throw new ApplicationException(Lang::get(
                    'backend::lang.field.invalid_type',
                    ['type' => gettype($fieldType)]
                ));
            }

            /*
             * Widget with configuration
             */
            if ($this->isFormWidget($fieldType) !== false) {
                $config['widget'] = $fieldType;
                $fieldType = 'widget';
            }

            $field->displayAs($fieldType, $config);
        }

        /*
         * Set field value
         */
        $field->value = $this->getFieldValue($field);

        /*
         * Apply the field name to the validation engine
         */
        $attrName = implode('.', HtmlHelper::nameToArray($field->fieldName));

        if ($this->model && method_exists($this->model, 'setValidationAttributeName')) {
            $this->model->setValidationAttributeName($attrName, $field->label);
        }

        /*
         * Check model if field is required
         */
        if ($field->required === null && $this->model && method_exists($this->model, 'isAttributeRequired')) {
            // Check nested fields
            if ($this->isNested) {
                // Get the current attribute level
                $nameArray = HtmlHelper::nameToArray($this->arrayName);
                unset($nameArray[0]);

                // Convert any numeric indexes to wildcards
                foreach ($nameArray as $i => $value) {
                    if (preg_match('/^[0-9]*$/', $value)) {
                        $nameArray[$i] = '*';
                    }
                }

                // Recombine names for full attribute name in rules array
                $attrName = implode('.', $nameArray) . ".{$attrName}";
            }

            $field->required = $this->model->isAttributeRequired($attrName);
        }

        /*
         * Get field options from model
         */
        $optionModelTypes = ['dropdown', 'radio', 'checkboxlist', 'balloon-selector'];
        if (in_array($field->type, $optionModelTypes, false)) {

            /*
             * Defer the execution of option data collection
             */
            $field->options(function () use ($field, $config) {
                $fieldOptions = $config['options'] ?? null;
                $fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
                return $fieldOptions;
            });
        }

        return $field;
    }
374895
public function add_before($name, $label = '', array $attributes = array(), array $rules = array(), $fieldname = null)
	{
		return $this->fieldset()->add_before($name, $label, $attributes, $rules, $fieldname);
	}
152637
public function addFields($fields)
    {
        if (!is_array($fields)) {
            $fields = array_map(function ($f) {
                return trim($f);
            }, explode(',', $fields));
        }

        $this->fields = array_merge($this->fields, $fields);

        return $this;
    }
584584
public function addFields($fields, $fieldset = null, $group = null)
    {
        if ($fields instanceof \SimpleXMLElement) {
            $fields = $fields->xpath('//field');
        }

        foreach ($fields as $field) {
            $this->addField($field, $fieldset, $group);
        }

        return $this;
    }
1032739
public function addCustomField($name, $class)
    {
        if (!$this->hasCustomField($name)) {
            return $this->customTypes[$name] = $class;
        }

        throw new \InvalidArgumentException('Custom field ['.$name.'] already exists on this form object.');
    }
525960
public function addFields($fields)
    {
        foreach ($fields as $field) {
            if (is_array($field)) {
                $this->addField(...$field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
555453
public function changeField($name, array $attributes)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $this->changeFields[$name] = $attributes;
        return $this;
    }
1352357
public function add($name, $field = null, $fieldset = null, $group = null)
    {
        return $this->form->add($name, $field, $fieldset, $group);
    }
1001707
public function setName($name)
    {
        $this->name = $name;
        $this->setValue($this->form->getFieldValue($this->name));
        return $this;
    }
640969
public function setGrid(GridInterface $grid = null)
    {
        $this->grid = $grid;

        if($grid === null) {
            $this->setItemType(null);
            $this->setItemTypeId(null);
            $this->setItemTypeClass(null);
        }

        return $this;
    }
380213
public static function getFieldset($name) {
        if (!isset(self::$fieldsets[$name])) {
            try {
                self::$fieldsets[$name] = Fieldset::i($name);
            } catch (Exception $e) {
                return false;
            }
        }

        return self::$fieldsets[$name];
    }
7195
public function addField(string $name, ColumnSchemaBuilder $definition): Table
    {
        $this->fields[] = new Field($name, $definition);

        return $this;
    }