Fuzz fill all form fields with random data

@param Element\NodeElement $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();
                    }
                }
            }
        }

    }
115929
def fill_form(hashtable, fields = [], map = {})
      hashtable, map = wrapper_hash(hashtable), wrapper_hash(map)

      fields = hashtable.keys.map(&:to_sym) if fields.empty?

      fields.each do |f|
        key = f
        key = map[f] if map.key?(f)

        el, val = send(f), hashtable[key]
        tag, it = el.send(:tag_name), el.send(:[], :type)

        if tag == 'input' && it == 'checkbox' # checkbox
          el.send(:set, val == 'true')
        elsif tag == 'select' # select
          el.send(:select, val)
        else
          el.send(:set, val)
        end
      end
    end
132668
public function config_form_definition(\MoodleQuickForm $mform) {
        $mform->addElement('header', 'header_specificsettings', get_string('specificsettings', 'customfield_checkbox'));
        $mform->setExpanded('header_specificsettings', true);

        $mform->addElement('selectyesno', 'configdata[checkbydefault]', get_string('checkedbydefault', 'customfield_checkbox'));
        $mform->setType('configdata[checkbydefault]', PARAM_BOOL);
    }
724441
public function formExtendFields($form)
    {
        /*
         * Show the username field if it is configured for use
         */
        if (
            UserSettings::get('login_attribute') == UserSettings::LOGIN_USERNAME &&
            array_key_exists('username', $form->getFields())
        ) {
            $form->getField('username')->hidden = false;
        }
    }
710194
public void handleFormElements(List<FormInput> formInputs) {
		try {
			Document dom = DomUtils.asDocument(browser.getStrippedDomWithoutIframeContent());
			for (FormInput input : formInputs) {
				LOGGER.debug("Filling in: " + input);
				setInputElementValue(formInputValueHelper.getBelongingNode(input, dom), input);
			}
		} catch (IOException | XPathExpressionException e) {
			LOGGER.error(e.getMessage(), e);
		}

	}
231623
public function setForm($form)
    {
        foreach ($this->namedLinkCompositeField->compositeDatabaseFields() as $field => $spec) {
            $fieldHandle = 'field' . $field;
            $this->{$fieldHandle}->setForm($form);
        }
//		$this->fieldPageID->setForm($form);
//		$this->fieldPageAnchor->setForm($form);
//		$this->fieldFileID->setForm($form);
//		$this->fieldCustomURL->setForm($form);
//		$this->fieldShortcode->setForm($form);
//		$this->fieldTitle->setForm($form);
//		$this->fieldLinkmode->setForm($form);

		parent::setForm($form);

        return $this;
	}
360211
public function setForm($form)
    {
        // Associate Fields with Form:
        
        $this->honeypot->setForm($form);
        $this->timestamp->setForm($form);
        
        // Call Parent Method:
        
        return parent::setForm($form);
    }
590325
static function registerForm (Form $form)
    {
        if (!in_array($form, self::$forms))
            array_push(self::$forms, $form);
    }
216185
public function form($form = null)
    {
        if (func_num_args() === 1) {
            $form = $form ?: [];
            $this->_form = $form;
            $this->set($form);
            return $this;
        }
        return $this->_form;
    }
590336
public function buildForm(array $form, FormStateInterface $form_state, $node = null)
    {
        $request = $this->requestStack->getCurrentRequest();

        $form['#method'] = 'get';
        $form['#action'] = url('node/'.$node->nid);
        $form['#after_build'][] = '::formAfterBuild';
        $form['#token'] = false;
        $form['#attributes'] = ['class' => [drupal_html_class($this->getFormId())]];

        $form[Search::PARAM_FULLTEXT_QUERY] = [
            '#type'          => 'textfield',
            '#default_value' => $request->query->get(Search::PARAM_FULLTEXT_QUERY),
            '#prefix'        => '<div class="input-group">',
            '#attributes'    => [
                'class'       => [],
                'placeholder' => $this->t("Specify your keywords"),
            ],
        ];

        // No need to use an input submit with GET method. Furthermore, it won't be
        // exposed as GET parameter with an input button.
        $form['submit'] = [
            '#type'    => 'button',
            '#content' => '<span class="fa fa-search"></span>',
            '#prefix'  => '<span class="input-group-btn">',
            '#suffix'  => '</span></div>',
        ];

        return $form;
    }
510332
public function instance_form_definition(\MoodleQuickForm $mform) {
        $field = $this->get_field();
        $config = $field->get('configdata');
        $type = $config['ispassword'] ? 'password' : 'text';
        $elementname = $this->get_form_element_name();
        $mform->addElement($type, $elementname, $this->get_field()->get_formatted_name(), 'size=' . (int)$config['displaysize']);
        $mform->setType($elementname, PARAM_TEXT);
        if (!empty($config['defaultvalue'])) {
            $mform->setDefault($elementname, $config['defaultvalue']);
        }
        if ($field->get_configdata_property('required')) {
            $mform->addRule($elementname, null, 'required', null, 'client');
        }
    }
425087
public function filterSucceeded(Form $form)
	{
		if ($this->snippets_set) {
			return;
		}

		$values = $form->getValues();

		if ($this->getPresenter()->isAjax()) {
			if (isset($form['group_action']['submit']) && $form['group_action']['submit']->isSubmittedBy()) {
				return;
			}
		}

		/**
		 * Per page
		 */
		$this->saveSessionData('_grid_per_page', $values->per_page);
		$this->per_page = $values->per_page;

		/**
		 * Inline edit
		 */
		if (isset($form['inline_edit']) && isset($form['inline_edit']['submit']) && isset($form['inline_edit']['cancel'])) {
			$edit = $form['inline_edit'];

			if ($edit['submit']->isSubmittedBy() || $edit['cancel']->isSubmittedBy()) {
				$id = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_id]');
				$primary_where_column = $form->getHttpData(
					Form::DATA_LINE,
					'inline_edit[_primary_where_column]'
				);

				if ($edit['submit']->isSubmittedBy() && !$edit->getErrors()) {
					$this->inlineEdit->onSubmit($id, $values->inline_edit);
					$this->getPresenter()->payload->_datagrid_inline_edited = $id;
					$this->getPresenter()->payload->_datagrid_name = $this->getName();
				} else {
					$this->getPresenter()->payload->_datagrid_inline_edit_cancel = $id;
					$this->getPresenter()->payload->_datagrid_name = $this->getName();
				}

				if ($edit['submit']->isSubmittedBy() && !empty($this->inlineEdit->onCustomRedraw)) {
					$this->inlineEdit->onCustomRedraw();
				} else {
					$this->redrawItem($id, $primary_where_column);
					$this->redrawControl('summary');
				}

				return;
			}
		}

		/**
		 * Inline add
		 */
		if (isset($form['inline_add']) && isset($form['inline_add']['submit']) && isset($form['inline_add']['cancel'])) {
			$add = $form['inline_add'];

			if ($add['submit']->isSubmittedBy() || $add['cancel']->isSubmittedBy()) {
				if ($add['submit']->isSubmittedBy() && !$add->getErrors()) {
					$this->inlineAdd->onSubmit($values->inline_add);

					if ($this->getPresenter()->isAjax()) {
						$this->getPresenter()->payload->_datagrid_inline_added = true;
					}
				}

				return;
			}
		}

		/**
		 * Filter itself
		 */
		$values = $values['filter'];

		foreach ($values as $key => $value) {
			/**
			 * Session stuff
			 */
			if ($this->remember_state && $this->getSessionData($key) != $value) {
				/**
				 * Has been filter changed?
				 */
				$this->page = 1;
				$this->saveSessionData('_grid_page', 1);
			}

			$this->saveSessionData($key, $value);

			/**
			 * Other stuff
			 */
			$this->filter[$key] = $value;
		}

		if (!empty($values)) {
			$this->saveSessionData('_grid_has_filtered', 1);
		}

		if ($this->getPresenter()->isAjax()) {
			$this->getPresenter()->payload->_datagrid_sort = [];

			foreach ($this->columns as $key => $column) {
				if ($column->isSortable()) {
					$this->getPresenter()->payload->_datagrid_sort[$key] = $this->link('sort!', [
						'sort' => $column->getSortNext(),
					]);
				}
			}
		}

		$this->reload();
	}
771963
public function setForm($form)
    {
        foreach ($this->fields as $field) {
            $field->setForm($form);
        }
        
        return parent::setForm($form);
    }
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;
    }
847003
private function getFormNodeId(\DOMElement $form)
    {
        return md5($form->getLineNo() . $form->getNodePath() . $form->nodeValue);
    }
716960
protected function InitForm()
    {
        $this->select  = $this->LoadElement();
        
        $this->AddNameField();
        $this->AddValueField();
        $this->AddLabelField();
        $this->AddOptionsField();
        
        $this->AddDisableFrontendValidationField();
        $this->AddRequiredField();
        $this->AddTemplateField();
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddSubmit();
    }
1145503
private function buildBasketElements($form, $basketElements)
    {
        if (null === $basketElements) {
            return;
        }

        if (!$basketElements instanceof \ArrayAccess && !\is_array($basketElements)) {
            throw new UnexpectedTypeException($basketElements, 'array or \ArrayAccess');
        }

        foreach ($basketElements as $basketElement) {
            $basketElementBuilder = $this->factory->createNamedBuilder($basketElement->getPosition(), 'form', $basketElement, [
                'property_path' => '['.$basketElement->getPosition().']',
                'auto_initialize' => false,
            ]);
            $basketElementBuilder->setErrorBubbling(false);

            $provider = $basketElement->getProductProvider();
            $provider->defineBasketElementForm($basketElement, $basketElementBuilder);

            $form->add($basketElementBuilder->getForm());
        }
    }