form elements for extra options for this particular export option
@param  \MUtil_Form $form Current form to add the form elements
@param  array $data current options set in the form
@return array Form elements
505671
public function getFormElements(&$form, &$data)
    {
        $element = $form->createElement('multiCheckbox', 'format');
        $element->setLabel($this->_('CSV options'))
                ->setMultiOptions(array(
                    'addHeader' => $this->_('Add headers with column names'),
                    'formatVariable' => $this->_('Export labels instead of field names'),
                    'formatAnswer' => $this->_('Format answers')
                ))
                ->setBelongsTo($this->getName())
                ->setSeparator(' ');
        $elements['format'] = $element;

        $element = $form->createElement('select', 'delimiter');
        $element->setLabel($this->_('Delimiter'))
                ->setMultiOptions(array(',' => ',', ';' => ';'))
                ->setBelongsTo($this->getName());
        $elements['delimiter'] = $element;

        return $elements;
    }
491089
public function alterFieldValues(Form $form, array &$values)
    {
        // Alter the form itself
        $form->alterFieldValues($values);

        // Alter the form's child forms recursively
        foreach ($form->getFields() as $name => $field) {
            if (method_exists($field, 'alterFieldValues')) {
                $fullName = $this->transformToDotSyntax($name);

                $subValues = (array) Arr::get($values, $fullName);
                $field->alterFieldValues($subValues);
                Arr::set($values, $fullName, $subValues);
            }
        }
    }
1038401
public function save($data, $form)
    {
        $request = $this->getRequest();
        $className = $this->config()->get('tree_class');

        // Existing or new record?
        $id = $data['ID'];
        if (is_numeric($id) && $id > 0) {
            $record = DataObject::get_by_id($className, $id);
            if ($record && !$record->canEdit()) {
                return Security::permissionFailure($this);
            }
            if (!$record || !$record->ID) {
                $this->httpError(404, "Bad record ID #" . (int)$id);
            }
        } else {
            if (!singleton($this->config()->get('tree_class'))->canCreate()) {
                return Security::permissionFailure($this);
            }
            $record = $this->getNewItem($id, false);
        }

        // save form data into record
        $form->saveInto($record, true);
        $record->write();
        $this->extend('onAfterSave', $record);
        $this->setCurrentPageID($record->ID);

        $message = _t(__CLASS__ . '.SAVEDUP', 'Saved.');
        if ($this->getSchemaRequested()) {
            $schemaId = Controller::join_links($this->Link('schema/DetailEditForm'), $id);
            // Ensure that newly created records have all their data loaded back into the form.
            $form->loadDataFrom($record);
            $form->setMessage($message, 'good');
            $response = $this->getSchemaResponse($schemaId, $form);
        } else {
            $response = $this->getResponseNegotiator()->respond($request);
        }

        $response->addHeader('X-Status', rawurlencode($message));
        return $response;
    }
340169
public function doSave($data, $form) {
        $config=CodeBankConfig::CurrentConfig();
        $form->saveInto($config);
        $config->write();
        
        $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
        return $this->getResponseNegotiator()->respond($this->request);
    }
281225
public function formToArray($form)
    {
        $result = [];
        if (preg_match_all('/<input[^>]*>/sm', $form, $inputs) !== false) {
            foreach ($inputs[0] as $input) {
                if (preg_match('/name=["\']([^"\']*)["\']\s+value=["\']([^"\']*)["\']/', $input, $match) !== false) {
                    if (count($match) === 3) {
                        $result[$match[1]] = $match[2];
                    }
                }
            }
        }

        return $result;
    }
1326002
public function define_form(&$form) {
        $form->addElement('header', '_commonsettings', get_string('profilecommonsettings', 'admin'));
        $this->define_form_common($form);

        $form->addElement('header', '_specificsettings', get_string('profilespecificsettings', 'admin'));
        $this->define_form_specific($form);
    }
335698
protected function fillForm(Element\NodeElement $form)
    {
        $inputs = $form->findAll('css', 'input[type="text"]');
        foreach ($inputs as $i)
        {
            /** @var  Element\NodeElement $i */
            if ($i->isVisible())
            {
                if ($i->hasAttribute('name'))
                {
                    $name = $i->getAttribute('name');
                    $value = $this->getFakerValue($name);
                }
                else
                {
                    $value = $this->faker()->text();
                }
                $i->setValue($value);
            }


        }

        $passwords = $form->findAll('css', 'input[type="password"]');
        $password = $this->faker()->password;
        foreach ($passwords as $p)
        {
            if ($p->isVisible())
            {
                $p->setValue($password);
            }
        }

        $selects = $form->findAll('css', 'select');
        foreach ($selects as $s)
        {
            /** @var  Element\NodeElement $s */
            if ($s->isVisible())
            {
                $s->selectOption($s->find('css', 'option')->getAttribute('name'));
            }
        }

        $checkboxes = $form->findAll('css', 'checkbox');
        foreach ($checkboxes as $c)
        {
            /** @var  Element\NodeElement $c */
            if ($c->isVisible())
            {
                $c->check();
            }
        }

        $radios = $form->findAll('css', 'input[type="radio"]');
        $radio_names = array();
        foreach ($radios as $r)
        {
            /** @var  Element\NodeElement $r */
            if ($r->isVisible())
            {
                if ($r->hasAttribute('name'))
                {
                    $name = $r->getAttribute('name');
                    if (!isset($radio_names[$name]))
                    {
                        $radio_names[$name] = true;
                        $r->click();
                    }
                }
            }
        }

    }
1247442
public function saveFormIntoRecord($data, $form)
    {
        $record = parent::saveFormIntoRecord($data, $form);

        // Note: Don't publish if versioned, since that's a separate action
        $ownerIsVersioned = $record && $record->hasExtension(Versioned::class);
        $ownerIsPublishable = $record && $record->hasExtension(RecursivePublishable::class);
        if ($ownerIsPublishable && !$ownerIsVersioned) {
            /** @var RecursivePublishable $record */
            $record->publishRecursive();
        }

        return $record;
    }
134775
public function doAdd($data, $form)
    {
        if ($this->addMember($form)) {
            $form->sessionMessage(
                _t('MemberProfiles.MEMBERADDED', 'The new member has been added.'),
                'good'
            );
        }

        return $this->redirectBack();
    }
459480
protected function getViewParameters(Request $request, Form $form = null, $data = null): array
    {
        $parameters = parent::getViewParameters($request, $form, $data);
        if ($this->family) {
            $parameters['family'] = $this->family;
        }

        return $parameters;
    }
678752
public static function execute(ContainerInterface $form, array $data)
    {
        self::$form = $form;
        $hasElements = isset($data['elements']) && is_array($data['elements']);
        if (!$hasElements) {
            return;
        }

        foreach ($data['elements'] as $name => $element) {
            $input = self::create($element);
            self::setSettings($input, $element);
            $input->setName($name);
            self::populateInputs($input, $element);
            $form->add($input);
        }
    }
634831
public function doSave($data, Form $form) {
        $record=$this->currentPage();
        
        if($record->canEdit()) {
            $form->saveInto($record);
            $record->write();
            
            $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_SAVED', '_Snippet has been saved')));
        }else {
            $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.PERMISSION_DENIED', '_Permission Denied')));
        }
        
        return $this->getResponseNegotiator()->respond($this->request);
    }
1049590
public static function form_radio($data = '', $value = '', $checked = false, $extra = '')
    {
        if (! is_array($data)) {
            $data = array('name' => $data);
        }

        $data['type'] = 'radio';
        return self::form_checkbox($data, $value, $checked, $extra);
    }
1100545
public function addElement(FieldsetInterface &$form, $name, $data)
    {
        if ($data['type'] == 'fieldset') {
            $fieldset = new Fieldset(['name' => $name]);
            foreach ($data['elements'] as $key => $def) {
                $this->addElement($fieldset, $key, $def);
            }
            $form->add($fieldset);
        } else {
            if (array_key_exists($data['type'], static::$_elementAlias)) {
                $class = static::$_elementAlias[$data['type']];
            } else if (
                is_subclass_of($data['type'], 'Slick\Form\ElementInterface')
            ) {
                $class = $data['type'];
            } else {
                throw new Exception\UnknownElementException(
                    "'{$data['type']}' is not a known alias or an implementation of " .
                    "Slick\\Form\\ElementInterface interface"
                );
            }

            /** @var Element $element */
            $element = new $class(['name' => $name]);

            if (isset($data['input'])) {
                $element->input = InputFilterFactory::createInput(
                    $data['input'],
                    $element->getName()
                );
            }

            if (!empty($data['validate'])) {
                $this->addValidation($element, $data['validate']);
            }

            foreach (array_keys($this->_elementProperties) as $key) {
                if (isset($data[$key])) {
                    $element->$key = $data[$key];
                }
            }

            $form->add($element);
        }
    }
948737
public function config_form_display(&$mform, $data = null) {

        $mform->addElement('checkbox', 'criteria_role['.$data->id.']', $this->get_title($data));

        if ($this->id) {
            $mform->setDefault('criteria_role['.$data->id.']', 1);
        }
    }
780533
public function plain(array $options = [], array $data = [])
    {
        $form = $this->setDependenciesAndOptions(
            $this->container->make($this->plainFormClass),
            $options,
            $data
        );

        $this->eventDispatcher->dispatch(new AfterFormCreation($form));

        $form->filterFields();

        return $form;
    }
450911
public function onFakeSubmit(&$form, &$data) {
        if ($this->useMultiRowForm) {
            //Check if the insert button was pressed and act upon that
            if ($this->hasNew() && isset($data['insert_button']) && $data['insert_button']) {
                    // Add a row
                    $model          = $this->getModel();
                    $mname          = $model->getName();
                    $data[$mname][] = $model->loadNew();
            }
        }
    }