Append spellchecking related fields.

@param Fieldset $fieldset Target fieldset

@return FrontPlugin
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;
    }
721695
public function addEavCatalogFields(SchemaSetupInterface $setup)
    {
        $connection = $setup->getConnection();
        $table      = $setup->getTable('catalog_eav_attribute');

        // Append a column 'is_displayed_in_autocomplete' into the db.
        $connection->addColumn(
            $table,
            'is_displayed_in_autocomplete',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                'nullable' => false,
                'default'  => '0',
                'comment'  => 'If attribute is displayed in autocomplete',
            ]
        );

        // Append a column 'is_used_in_spellcheck' to the table.
        $connection->addColumn(
            $table,
            'is_used_in_spellcheck',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                'nullable' => false,
                'default'  => '1',
                'comment'  => 'If fuzziness is used on attribute',
            ]
        );

        // Append facet_min_coverage_rate to the table.
        $connection->addColumn(
            $table,
            'facet_min_coverage_rate',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                'unsigned' => true,
                'nullable' => false,
                'default'  => 90,
                'comment'  => 'Facet min coverage rate',
            ]
        );

        // Append facet_max_size to the table.
        $connection->addColumn(
            $table,
            'facet_max_size',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                'unsigned' => true,
                'nullable' => false,
                'default'  => '10',
                'comment'  => 'Facet max size',
            ]
        );

        // Append facet_sort_order to the table.
        $connection->addColumn(
            $table,
            'facet_sort_order',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                'nullable' => false,
                'default'  => \Smile\ElasticsuiteCore\Search\Request\BucketInterface::SORT_ORDER_COUNT,
                'length'   => 25,
                'comment'  => 'The sort order for facet values',
            ]
        );
    }
623997
protected function fieldset()
    {

        return $this->grid->fieldset('user-fieldset', function (Fieldset $fieldset) {
                    $fieldset->control('input:text', 'email')
                            ->label(trans('antares/foundation::label.users.email'));

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

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

                    $fieldset->control('select', 'roles[]')
                            ->label(trans('antares/foundation::label.users.roles'))
                            ->attributes(['class' => 'w470'])
                            ->options(function () {
                                return app('antares.role')->members()->pluck('name', 'id');
                            })
                            ->value(function ($row) {
                                $roles = [];
                                foreach ($row->roles as $row) {
                                    $roles[] = $row->id;
                                }
                                return $roles;
                            });



                    $fieldset->control('remote_select', 'select')
                            ->label('Remote Select')
                            ->options([
                                ['0' => 'please select option...']
                            ])
                            ->attributes([
                                'id'            => 'select-infinity',
                                'options'       => ['placeholder' => 'Search for a repo ...'],
                                'pluginOptions' => [
                                    'allowClear'              => true,
                                    'minimumInputLength'      => 1,
                                    'minimumResultsForSearch' => 'Infinity',
                                    'ajax'                    => [
                                        'url'      => handles('antares/foundation::users/elements'),
                                        'dataType' => 'json',
                                        'delay'    => 250,
                                        'cache'    => true
                                    ],
                                ],
                    ]);
                    $fieldset->control('button', 'cancel')
                            ->field(function() {
                                return app('html')->link(handles("antares/foundation::users"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
                            });

                    $fieldset->control('button', 'button')
                            ->attributes(['type' => 'submit', 'value' => trans('Submit'), 'class' => 'btn btn--md btn--primary mdl-button mdl-js-button mdl-js-ripple-effect'])
                            ->value(trans('Submit'));
                });
    }
814382
public function addHlblock($fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('NAME', 'TABLE_NAME'));

        $lang = array();
        if (isset($fields['LANG'])) {
            $lang = $fields['LANG'];
            unset($fields['LANG']);
        }

        $fields['NAME'] = ucfirst($fields['NAME']);

        $result = HL\HighloadBlockTable::add($fields);
        if ($result->isSuccess()) {
            $this->replaceHblockLangs($result->getId(), $lang);
            return $result->getId();
        }

        $this->throwException(__METHOD__, implode(', ', $result->getErrors()));
    }
813879
public static function set_fields($obj, $fieldset = null)
	{
		static $_generated = array();
		static $_tabular_rows = array();

		$class = is_object($obj) ? get_class($obj) : $obj;
		if (is_null($fieldset))
		{
			$fieldset = \Fieldset::instance($class);
			if ( ! $fieldset)
			{
				$fieldset = \Fieldset::forge($class);
			}
		}

		// is our parent fieldset a tabular form set?
		$tabular_form = is_object($fieldset->parent()) ? $fieldset->parent()->get_tabular_form() : false;

		// don't cache tabular form fieldsets
		if ( ! $tabular_form)
		{
			! array_key_exists($class, $_generated) and $_generated[$class] = array();
			if (in_array($fieldset, $_generated[$class], true))
			{
				return $fieldset;
			}
			$_generated[$class][] = $fieldset;
		}

		$primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
		$primary_key = count($primary_keys) === 1 ? reset($primary_keys) : false;
		$properties = is_object($obj) ? $obj->properties() : $class::properties();

		if ($tabular_form and $primary_key and ! is_object($obj))
		{
			isset($_tabular_rows[$class]) or $_tabular_rows[$class] = 0;
		}

		foreach ($properties as $p => $settings)
		{
			if (\Arr::get($settings, 'skip', in_array($p, $primary_keys)))
			{
				continue;
			}

			if (isset($settings['form']['options']))
			{
				foreach ($settings['form']['options'] as $key => $value)
				{
					is_array($value) or $settings['form']['options'][$key] = \Lang::get($value, array(), false) ?: $value;
				}
			}

			// field attributes can be passed in form key
			$attributes = isset($settings['form']) ? $settings['form'] : array();
			// label is either set in property setting, as part of form attributes or defaults to fieldname
			$label = isset($settings['label']) ? $settings['label'] : (isset($attributes['label']) ? $attributes['label'] : $p);
			$label = \Lang::get($label, array(), false) ?: $label;

			// change the fieldname and label for tabular form fieldset children
			if ($tabular_form and $primary_key)
			{
				if (is_object($obj))
				{
					$p = $tabular_form.'['.$obj->{$primary_key}.']['.$p.']';
				}
				else
				{
					$p = $tabular_form.'_new['.$_tabular_rows[$class].']['.$p.']';
				}
				$label = '';
			}

			// create the field and add validation rules
			$field = $fieldset->add($p, $label, $attributes);
			if ( ! empty($settings['validation']))
			{
				foreach ($settings['validation'] as $rule => $args)
				{
					if (is_int($rule) and is_string($args))
					{
						$args = array($args);
					}
					else
					{
						array_unshift($args, $rule);
					}

					call_fuel_func_array(array($field, 'add_rule'), $args);
				}
			}
		}

		// increase the row counter for tabular row fieldsets
		if ($tabular_form and $primary_key and ! is_object($obj))
		{
			$_tabular_rows[$class]++;
		}

		return $fieldset;
	}
119984
public function renderFieldset(Fieldset $fieldset)
	{
		// Create a new renderer and render the content
		$fieldsetRenderer = new static($this->csrfProvider);

		// Generate all the content
		foreach ($fieldset as $item)
		{
			$fieldsetRenderer->render($item);
		}

		$content = $fieldsetRenderer->getRenderedForm();

		// Create the fieldset tag and add the content
		$tag = Html::tag('fieldset', $fieldset->getAttributes(), $content);

		// Make sure everything is added to the parent table
		$cell = new Table\Cell($tag);
		$cell->setAttributes(['colspan' => 2]);

		$this->table->addCell($cell);
		$this->table->addRow();

		return '';
	}
1062067
public function addMetaField(array $fields)
    {
        $fields = parent::addMetaField($fields);
        foreach ($fields as $key => &$field) {
            if ($field['type'] === 'fieldset') {
                $field['fields'][static::Meta] = $fields[static::Meta];
                unset($fields[static::Meta]);
                break;
            }
        }
        return $fields;
    }
10382
protected function renderFieldset(Fieldset $fieldset, $groupActions = false)
    {
        $fieldsetElement = new HtmlElement('fieldset');
        $id              = $fieldset->getAttribute('id') ? : $fieldset->getName();
        $parent          = $this->getElement();

        $fieldsetElement->addAttribute('id', $id);

        /**
         * This changes the scope of the current element,
         * so that the child elements (the ones that are about to be rendered),
         * will be set on the fieldset.
         * Then change it back again so that the fieldset will be added to the form.
         */
        $this
            ->setElement($fieldsetElement)
            ->renderElements($fieldset, $groupActions)
            ->setElement($parent);

        return $fieldsetElement;
    }
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']);
                });
    }
212882
public function renderFields($fieldset = null, $group = null, array $options = [])
    {
        $output = '';

        foreach ($this->getFields($fieldset, $group) as $field) {
            $output .= "\n" . $field->render($options);
        }

        return $output;
    }
62061
public function parseFieldsets(array $fieldsets)
    {
        foreach ($fieldsets as $key => $fields) {
            if (is_array($fields)) {
                $fieldsets[$key] = implode(',', $fields);
            }
        }

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

        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);
	}
386511
protected function prepare(): void
  {
    if (!$this->prepared)
    {
      $this->fieldSets->prepare('');

      $this->prepared = true;
    }
  }
357537
public function addColumn($fieldsets, $class = null)
    {
        if (!is_array($fieldsets)) {
            $fieldsets = [$fieldsets];
        }
        foreach ($fieldsets as $i => $num) {
            $fieldsets[$i] = (int)$num - 1;
        }
        if (null === $class) {
            $class = 'pop-form-column-' . (count($this->columns) + 1);
        }
        $this->columns[$class] = $fieldsets;
        return $this;
    }
903195
public function appendPlugin(Plugin ...$plugins)
    {
        foreach ($plugins as $plugin) {
            $this->appendPlugins[] = $plugin;
        }

        return $this;
    }
868607
public function resolveFields(Collection $fieldsets, $key = null)
    {
        $name          = $fieldsets->first()->name;
        $name instanceof \Closure and $name          = sprintf('fieldset-%d', $fieldsets->count());
        $formName      = str_slug($name);
        if (!app('antares.installed') or ! ($configuration = $this->validate($formName, $key)) !== false) {
            return false;
        }
        $editable    = array_get($configuration, 'editable', []);
        $displayable = array_get($configuration, 'displayable', []);
        /** continue recreate form configuration * */
        /** form can have more than one fieldset spec * */
        $return      = [];
        foreach ($fieldsets as $fieldsetCopy) {
            array_push($return, $fieldsetCopy);
        }

        $clone = $fieldsets;
        foreach ($clone as $fieldset) {
            if (empty($fieldset->controls)) {
                return;
            }
            $controls = [];
            /** for each control in fieldset * */
            foreach ($fieldset->controls as $control) {
                if (!$this->display($control, $displayable)) {
                    continue;
                }
                $control = $this->resolveEditableField($control, $editable);
                array_push($controls, $control);
            }
            $fieldset->setControls($controls);
        }
        return $clone;
    }
835335
protected function addThemeColorPicker(FieldList $fields)
    {
        // Only show theme colour selector if enabled
        if (!$this->owner->config()->get('enable_theme_color_picker')) {
            return $this;
        }

        $fonts = $this->owner->config()->get('theme_fonts');

        // Import each font via the google fonts api to render font preview
        foreach ($fonts as $fontTitle) {
            $fontFamilyName = str_replace(' ', '+', $fontTitle);
            Requirements::css("//fonts.googleapis.com/css?family=$fontFamilyName");
        }

        $fields->addFieldsToTab(
            'Root.ThemeOptions',
            [
                FontPickerField::create(
                    'MainFontFamily',
                    _t(
                        __CLASS__ . '.MainFontFamily',
                        'Main font family'
                    ),
                    $fonts
                ),
                 ColorPickerField::create(
                     'HeaderBackground',
                     _t(
                         __CLASS__ . '.HeaderBackground',
                         'Header background'
                     ),
                     $this->getThemeOptionsExcluding([
                         'default-accent',
                     ])
                 ),
                 ColorPickerField::create(
                     'NavigationBarBackground',
                     _t(
                         __CLASS__ . '.NavigationBarBackground',
                         'Navigation bar background'
                     ),
                     $this->getThemeOptionsExcluding([
                         'default-accent',
                     ])
                 ),
                 ColorPickerField::create(
                     'CarouselBackground',
                     _t(
                         __CLASS__ . '.CarouselBackground',
                         'Carousel background'
                     ),
                     $this->getThemeOptionsExcluding([
                         'default-accent',
                     ])
                 )->setDescription(
                     _t(
                         __CLASS__ . '.CarouselBackgroundDescription',
                         'The background colour of the carousel when there is no image set.'
                     )
                 ),
                 ColorPickerField::create(
                     'FooterBackground',
                     _t(
                         __CLASS__ . '.FooterBackground',
                         'Footer background'
                     ),
                     $this->getThemeOptionsExcluding([
                         'light-grey',
                         'white',
                         'default-accent',
                     ])
                 ),
                 ColorPickerField::create(
                     'AccentColor',
                     _t(
                         __CLASS__ . '.AccentColor',
                         'Accent colour'
                     ),
                     $this->getThemeOptionsExcluding([
                         'light-grey',
                         'white',
                         'default-background',
                     ])
                 )->setDescription(
                     _t(
                         __CLASS__ . '.AccentColorDescription',
                         'Affects colour of buttons, current navigation items, etc. '.
                         'Please ensure sufficient contrast with background colours.'
                     )
                 ),
                 ColorPickerField::create(
                     'TextLinkColor',
                     _t(
                         __CLASS__ . '.TextLinkColor',
                         'Text link colour'
                     ),
                     $this->getThemeOptionsExcluding([
                         'black',
                         'light-grey',
                         'dark-grey',
                         'white',
                         'default-background',
                     ])
                 ),
            ]
        );

        return $this;
    }