User form section.

@param  \Orchestra\Contracts\Html\Form\Fieldset  $fieldset
@param  \Illuminate\Support\Fluent  $model

@return void
489971
protected function userForm(Fieldset $fieldset, Fluent $model): void
    {
        $fieldset->control('input:email', 'email')
            ->label(\trans('orchestra/foundation::label.users.email'));

        $fieldset->control('password', 'password')
            ->label(\trans('orchestra/foundation::label.users.password'));

        $fieldset->control('text', 'fullname')
            ->label(\trans('orchestra/foundation::label.users.fullname'))
            ->value('Administrator');
    }
235661
def save_formset(self, request, form, formset, change):
        
        formset.save()

        for form in formset.forms:
            if hasattr(form, 'nested_formsets') and form not in formset.deleted_forms:
                for nested_formset in form.nested_formsets:
                    self.save_formset(request, form, nested_formset, change)
193786
private function addSearchFields(Fieldset $fieldset)
    {
        $fieldset->addField(
            'search_weight',
            'select',
            [
                'name' => 'search_weight',
                'label' => __('Search Weight'),
                'values' => $this->weightSource->getOptions(),
            ],
            'is_searchable'
        );

        $fieldset->addField(
            'is_used_in_spellcheck',
            'select',
            [
                'name'   => 'is_used_in_spellcheck',
                'label'  => __('Used in spellcheck'),
                'values' => $this->booleanSource->toOptionArray(),
            ],
            'search_weight'
        );

        return $this;
    }
1374414
public static function forge($fieldset = 'default')
	{
		if (is_string($fieldset))
		{
			($set = \Fieldset::instance($fieldset)) and $fieldset = $set;
		}

		if ($fieldset instanceof Fieldset)
		{
			if ($fieldset->validation(false) != null)
			{
				throw new \DomainException('Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.');
			}
		}

		return new static($fieldset);
	}
144473
public function validate(Model $model, $set) {
        if (!isset($model->validations[$set])) {
            throw new OutOfBoundsException(sprintf('Validation set %s does not exist', $set));
        }

        $rules = $model->validations[$set];
        $settings = $this->settings[$model->alias];

        // Add default messages second
        if ($settings['useDefaults']) {
            $rules = $this->_applyMessages($model, $rules);
        }

        // Merge in case there are other behaviors modifying the rules
        $model->validate = Hash::merge($model->validate, $rules);

        return $model;
    }
491803
public function form($model)
    {
        return $this->form->of('orchestra.users', function (FormGrid $form) use ($model) {
            $form->resource($this, 'orchestra/foundation::users', $model);

            $form->hidden('id');

            $form->fieldset(function (Fieldset $fieldset) {
                $fieldset->control('input:text', 'email')
                    ->label(trans('orchestra/foundation::label.users.email'));

                $fieldset->control('input:text', 'fullname')
                    ->label(trans('orchestra/foundation::label.users.fullname'));

                $fieldset->control('input:password', 'password')
                    ->label(trans('orchestra/foundation::label.users.password'));

                $fieldset->control('select', 'roles[]')
                    ->label(trans('orchestra/foundation::label.users.roles'))
                    ->attributes(['multiple' => true])
                    ->options(function () {
                        $roles = app('orchestra.role');

                        return $roles->pluck('name', 'id');
                    })
                    ->value(function ($user) {
                        // get all the user roles from objects
                        return $user->roles()->get()->pluck('id')->all();
                    });
            });
        });
    }
1032405
protected function saveFieldsets($model)
    {
        $fieldsets = input('fieldset', []);
        if (empty($fieldsets)) {
            return false;
        }
        foreach ($fieldsets as $name) {
            $fieldset = Fieldsets::query()->firstOrCreate(['name' => $name]);
            FieldFieldsets::query()->firstOrCreate([
                'fieldset_id' => $fieldset->id,
                'field_id'    => $model->id
            ]);
        }
    }
1352357
public function add($name, $field = null, $fieldset = null, $group = null)
    {
        return $this->form->add($name, $field, $fieldset, $group);
    }
1036025
public function initBySetting($model, $setting)
    {
        parent::initBySetting($model, $setting);
        $this->model = $model;
        if (is_array($setting)) {
            if (!isset($setting['remote_class_type'])) {
                throw new \Stack\Exception\MissingSetting('"remote_class_type" missing for the OneToMany relation.');
            }
            if (!isset($setting['related_attribute_name'])) {
                throw new \Stack\Exception\MissingSetting('"related_attribute_name" missing for the OneToMany relation.');
            }
            if (isset($setting['filter_list'])) {
                $this->filterList = $setting['filter_list'];
            }
            if (isset($setting['unique_remote'])) {
                $this->uniqueRemote = !!$setting['unique_remote'];
            }
            $this->remoteModelType = $setting['remote_class_type'];
            $this->relatedAttributeName = $setting['related_attribute_name'];
        }
    }
251029
public function updateSettingsFields(FieldList $fields)
    {
        // Define Placeholder:
        
        $placeholder = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');
        
        // Create Settings Fields:
        
        $fields->addFieldToTab(
            'Root.Settings',
            FieldSection::create(
                'AppearanceSettings',
                $this->owner->fieldLabel('AppearanceSettings'),
                [
                    $template = DropdownField::create(
                        'MyTemplateID',
                        $this->owner->fieldLabel('MyTemplateID'),
                        Template::get()->map()
                    )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                    $layout = DropdownField::create(
                        'MyLayoutID',
                        $this->owner->fieldLabel('MyLayoutID'),
                        Layout::get()->map()
                    )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
                ]
            )
        );
        
        // Check Permissions and Modify Fields:
        
        if (!Permission::check(['ADMIN', 'SILVERWARE_PAGE_TEMPLATE_CHANGE'])) {
            $fields->makeFieldReadonly($template);
        }
        
        if (!Permission::check(['ADMIN', 'SILVERWARE_PAGE_TEMPLATE_CHANGE'])) {
            $fields->makeFieldReadonly($layout);
        }
    }
976435
protected function transformFieldset(Fieldset $fieldset)
    {
        $controls = [];

        foreach ($fieldset->controls() as $control) {
            $type = $control->get('type');

            if (!in_array($type, self::$protectedTypes)) {
                $controls[] = $this->transformControlField($control);
            }
        }

        $this->fieldsets[] = [
            'name'     => $fieldset->getName(),
            'controls' => $controls,
        ];
    }
1309489
protected function _tag_open_FIELDSET($param)
    {

        $this->parsingCss->save();
        $this->parsingCss->analyse('fieldset', $param);

        $amountHtmlCodes = count($this->parsingHtml->code);

        // get height of LEGEND element and make fieldset corrections
        for ($tempPos = $this->_parsePos + 1; $tempPos<$amountHtmlCodes; $tempPos++) {
            $action = $this->parsingHtml->code[$tempPos];
            if ($action->getName() === 'fieldset') {
                break;
            }
            if ($action->getName() === 'legend' && !$action->isClose()) {
                $legendOpenPos = $tempPos;

                $sub = $this->createSubHTML();
                $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1);

                $amountSubHtmlCodes = count($sub->parsingHtml->code);
                $res = null;
                for ($sub->_parsePos = 0; $sub->_parsePos<$amountSubHtmlCodes; $sub->_parsePos++) {
                    $action = $sub->parsingHtml->code[$sub->_parsePos];
                    $sub->_executeAction($action);

                    if ($action->getName() === 'legend' && $action->isClose()) {
                        break;
                    }
                }

                $legendH = $sub->_maxY;
                $this->_destroySubHTML($sub);

                $move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03;

                $param['moveTop'] = $legendH / 2;

                $node = $this->parsingHtml->code[$legendOpenPos];
                $node->setParam('moveTop', - ($legendH / 2 + $move));
                $node->setParam('moveLeft', 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l']);
                $node->setParam('moveDown', $move);
                break;
            }
        }
        $this->parsingCss->load();

        return $this->_tag_open_DIV($param, 'fieldset');
    }
1067610
protected function setupFieldset(Fieldset $fieldset, BannedEmail $bannedEmail)
    {
        $fieldset->control('input:text', 'email')
                ->value($bannedEmail->getEmail())
                ->label(trans('antares/ban_management::label.rule.email'));

        $fieldset->control('input:text', 'expired_at')
                ->value($bannedEmail->getExpirationDate() ? $bannedEmail->getExpirationDate()->toDateString() : '')
                ->attributes([
                    'class' => 'datepicker-expired_at',
                ])
                ->label(trans('antares/ban_management::label.rule.expiration_date'));

        $fieldset->control('input:text', 'internal_reason')
                ->value($bannedEmail->getInternalReason())
                ->label(trans('antares/ban_management::label.rule.note'));


        $fieldset->control('input:textarea', 'reason')
                ->value($bannedEmail->getReason())
                ->label(trans('antares/ban_management::label.rule.reason'));


        $fieldset->control('button', 'button')
                ->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
                ->value(trans('antares/foundation::label.save_changes'));

        $fieldset->control('button', 'cancel')
                ->field(function() {
                    return app('html')->link(handles('antares::ban_management/bannedemails'), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
                });
    }
1272533
public function importFields($model, $fields = null)
    {
        $this->model = $model;
        $this->form = $this->owner;

        if ($fields === false) {
            return;
        }

        if (!$fields) {
            if ($model->only_fields) {
                $fields = $model->only_fields;
            } else {
                $fields = [];
                // get all field-elements
                foreach ($model->elements as $field => $f_object) {
                    if ($f_object instanceof \atk4\data\Field
                        && $f_object->isEditable()
                        && !$f_object->isHidden()
                    ) {
                        $fields[] = $field;
                    }
                }
            }
        }

        if (!is_array($fields)) {
            $fields = [$fields];
        }

        // import fields one by one
        foreach ($fields as $field) {
            $this->importField($field);
        }

        // set update hook
        if (!$this->_hook_set) {
            $this->owner->addHook('update', array($this, 'update'));
            $model->addHook('afterLoad', array($this, 'setFields'));
            $this->_hook_set = true;
        }

        return $this;
    }
971797
public function setup(Model $model, $settings = array()) {
		if (!isset($this->settings[$model->alias])) {
			$this->settings[$model->alias] = array('label' => 'name', 'slug' => 'slug');
		}

		$this->settings[$model->alias] = array_merge(
			$this->settings[$model->alias], (array)$settings
		);

		if (!$model->hasField($this->settings[$model->alias]['label'])) {
			$this->settings[$model->alias]['label'] = $model->displayField;
		}
	}
1060671
public function build(Fieldset $fieldset, SettingsContract $settings)
    {
        $cookieTracking = $settings->getValueByName('cookie_tracking');

        $fieldset->control('input:hidden', 'cookie_tracking')->value(0);

        $fieldset->control('input:checkbox', 'cookie_tracking')
                ->value(1)
                ->attributes($cookieTracking ? ['checked' => 'checked'] : [])
                ->label('Cookie tracking');

        $fieldset->control('input:text', 'max_failed_attempts')
                ->value($settings->getValueByName('max_failed_attempts'))
                ->label('Max failed attempts');

        $fieldset->control('input:text', 'attempts_decay_minutes')
                ->value($settings->getValueByName('attempts_decay_minutes'))
                ->label('Attempts decay minutes');
    }
871545
public function unshift(FormField $field)
    {
        if ($field instanceof Tab || $field instanceof TabSet) {
            $field->setTabSet($this);
        }
        parent::unshift($field);
    }