Add field that records how long it took to submit the form.
This should be longer than 1 second, otherwise we suspect spammy
behavior.

@return void
769910
public function addTimestampValidation() {
        // Add timestamp-based spam counter-measure
        $this->addElement(
            'hidden', self::TIMESTAMP_FIELD_KEY, array(
            'validators' => array(new Garp_Validate_Duration)
            )
        );
        // If the form is submitted, do not set the value.
        if (!$this->getValue(self::TIMESTAMP_FIELD_KEY)) {
            $now = time();
            $this->getElement(self::TIMESTAMP_FIELD_KEY)->setValue($now);
        }
    }
122868
protected function InitForm()
    {
        $this->logout = $this->LoadElement();
        $this->AddNextUrlField();
        $this->AddCssIDField();
        $this->AddCssClassField();
        $this->AddTemplateField();
        $this->AddSubmit();
    }
149738
protected function add_cohort_upload_buttons() {
        $mform = $this->_form;

        $buttonarray = array();

        $submitlabel = get_string('uploadcohorts', 'cohort');
        $buttonarray[] = $mform->createElement('submit', 'submitbutton', $submitlabel);

        $previewlabel = get_string('preview', 'cohort');
        $buttonarray[] = $mform->createElement('submit', 'previewbutton', $previewlabel);
        $mform->registerNoSubmitButton('previewbutton');

        $buttonarray[] = $mform->createElement('cancel');

        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
        $mform->closeHeaderBefore('buttonar');
    }
193340
protected function InitForm()
    {
        $this->htmlCode = $this->LoadElement();
        $name = 'Code';
        $this->AddField(new Textarea($name, $this->htmlCode->GetCode()));
        $this->SetRequired($name);
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddSubmit();
    }
593374
private function InitForm()
    {
        $this->AddCategoryField();
        $this->AddTitleField();
        $this->AddTeaserField();
        $this->AddTextField();
        $this->AddPublishField();
        $this->AddPublishFromDateField();
        $this->AddPublishFromHourField();
        $this->AddPublishFromMinuteField();
        $this->AddPublishToDateField();
        $this->AddPublishToHourField();
        $this->AddPublishToMinuteField();
        $this->AddAuthorField();
        $this->AddSubmit();
    }
1047491
public static function addFields()
    {
        $tags = ['text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*'];
        foreach ($tags as $tag) {
            //We have to remove tags before replacing them.
            wpcf7_remove_form_tag($tag);
        }
        wpcf7_add_form_tag($tags, [self::class, 'addCustomFields'], true);
    }
598585
public function populateFields()
    {
        if (count($this->submittedData) < 1) {
            return;
        }
        array_map(
            function (FormField &$field) {
                if (isset($this->submittedData[$field->getName()])) {
                    $raw = $this->submittedData[$field->getName()];

                    $sanitized = $field->sanitize($raw);
                    $field->setValue($sanitized);
                } else {
                    // Unset value (see: checkboxes where value only sent when checkbox was checked
                    if ($field->getType() == FormField::TYPE_CHECKBOX) {
                        $field->setValue(null);
                    }
                }
            },
            $this->getFields()
        );
    }
831404
public function edit_field_add($mform) {
        // Create the form field.
        $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
        $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display!
    }
693338
public function edit_field_add($mform) {
        // Get the current calendar in use - see MDL-18375.
        $calendartype = \core_calendar\type_factory::get_calendar_instance();

        // Check if the field is required.
        if ($this->field->required) {
            $optional = false;
        } else {
            $optional = true;
        }

        // Convert the year stored in the DB as gregorian to that used by the calendar type.
        $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1);
        $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1);

        $attributes = array(
            'startyear' => $startdate['year'],
            'stopyear'  => $stopdate['year'],
            'optional'  => $optional
        );

        // Check if they wanted to include time as well.
        if (!empty($this->field->param3)) {
            $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes);
        } else {
            $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes);
        }

        $mform->setType($this->inputname, PARAM_INT);
        $mform->setDefault($this->inputname, time());
    }
757599
public function add() {
        global $CFG, $USER, $DB;

        unset($this->id);
        $this->module       = 'blog';
        $this->userid       = (empty($this->userid)) ? $USER->id : $this->userid;
        $this->lastmodified = time();
        $this->created      = time();

        // Insert the new blog entry.
        $this->id = $DB->insert_record('post', $this);

        if (!empty($CFG->useblogassociations)) {
            $this->add_associations();
        }

        core_tag_tag::set_item_tags('core', 'post', $this->id, context_user::instance($this->userid), $this->tags);

        // Trigger an event for the new entry.
        $event = \core\event\blog_entry_created::create(array(
            'objectid'      => $this->id,
            'relateduserid' => $this->userid
        ));
        $event->set_blog_entry($this);
        $event->trigger();
    }
902702
protected function autocompletefield() {
		if ( ! $this->autocompleted) {
			$fieldname = $this->get('name', null);
			if ($fieldname !== null && ($autovalue = $this->form->autovalue($fieldname)) !== null) {
				if ($this->get('value', false) == $autovalue) {
					$this->checked();
				}
			}
			$this->autocompleted = true;
		}
	}
1161773
private function AddPublishToDateField()
    {
        $name = 'PublishToDate';
        $to = $this->article->GetPublishTo();
        $field = Input::Text($name, $to ? $to->ToString($this->dateFormat) : '');
        $field->SetHtmlAttribute('data-type', 'date');
        $this->AddField($field);
    }
1045213
public function add(FormField $field) {
		if($this->owner->hasTabSet()) {
			$before = ($this->tab == "Main" && $this->owner->dataFieldByName("Content")) ? "Content" : null;
			$this->owner->addFieldToTab("Root.{$this->tab}",$field, $before);
		}
		else {
			$this->owner->push($field);
		}
	}
707102
public function edit_field_add($mform) {
        $size = $this->field->param1;
        $maxlength = $this->field->param2;
        $fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');

        // Create the form field.
        $mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
        $mform->setType($this->inputname, PARAM_TEXT);
    }
966688
private function AddSmtpPortField()
    {
        $name = 'SmtpPort';
        $field = Input::Text($name, $this->settings->GetSmtpPort());
        $this->AddField($field);
        $this->AddValidator($name, new Integer(1, 65535));
    }
179194
private function AddUrlField()
    {
        $name = 'Url';
        $this->AddField(Input::Text($name, $this->page->GetUrl()));
        $this->SetRequired($name);
        $this->AddValidator($name, DatabaseCount::UniqueFieldAnd($this->page, $name, $this->SiteCondition()));
    }
1068941
private function submit ()
    {
        foreach ($this->getFields() as $field)
            /* @var $field Field */
            $field->submit();
        $this->isCallbacksubmitted = true;
        foreach ($this->callback as $callback)
            if (is_callable($callback))
                call_user_func($callback, $this);
    }