Skip to content

Instantly share code, notes, and snippets.

@gerritvanaaken
Last active January 17, 2023 09:01
Show Gist options
  • Save gerritvanaaken/17958a84586502d7d0711fd6a9fe6cd5 to your computer and use it in GitHub Desktop.
Save gerritvanaaken/17958a84586502d7d0711fd6a9fe6cd5 to your computer and use it in GitHub Desktop.
Complete List of Processwire Form Params
// API
https://processwire.com/api/ref/inputfield/
// Form wrap
$form = wire('modules')->get("InputfieldForm");
$form->action = "./#anfrage";
$form->method = "post";
$form->attr("id+name",'contactform');
$form->attr('class', 'form formular__box');
// Field Text
$field = wire('modules')->get("InputfieldText");
$field->label = "Vorname";
$field->attr('id+name','forename');
$field->attr('class', $field->attr("class").' input input--text');
$field->required(true);
$field->skipLabel = Inputfield::skipLabelHeader;
$field->wrapClass("superwrap");
$field->prependMarkup('<div>');
$field->setMarkup = '{out}';
$field->appendMarkup('</div>');
$form->append($field);
// Field Date
$field = wire('modules')->get("InputfieldDatetime");
$field->label = "Datum";
$field->attr('id+name','mydate');
$field->dateInputFormat = 'd.m.Y';
$field->inputType = "html";
$field->dateMin = $datemin;
$field->attr('value', $datemin);
$field->required(true);
$field->prependMarkup('<div>');
$field->setMarkup = '{out}';
$field->appendMarkup('</div>');
$form->append($field);
// Field Select
$field = wire('modules')->get("InputfieldSelect");
$field->attr('id+name','auswahl');
$field->addOption('0', 'nichts');
$field->addOption('1', 'einer');
$field->addOption('2', 'viele');
$form->append($field);
// Field Radios
$field = wire('modules')->get("InputfieldRadios");
$field->attr('id+name','auswahl');
$field->optionColumns(1);
$field->addOption('0', 'nichts');
$field->addOption('1', 'einer');
$field->addOption('2', 'viele');
$form->append($field);
// Single Checkbox
$field = wire('modules')->get("InputfieldCheckbox");
$field->attr('id+name','legalcheck');
$field->label = "Headline for this field"; // cannot be skipped, must be PW bug, remove via css or js
$field->checkboxLabel = "Yes, I do approve";
$field->checked = true;
$form->append($field);
// Multi-Checkboxes
$field = wire('modules')->get("InputfieldCheckbox");
$field->attr('id+name','legalcheck');
$field->addOption('0', 'Erdbeere');
$field->addOption('1', 'Vanille');
$field->addOption('2', 'Banane');
$form->append($field);
// Fieldset
$fieldset = wire('modules')->get("InputfieldFieldset");
$fieldset->attr('class','veloform__fieldset');
// here come one or more fields
$fieldset->append($field)
// Submit Button
$submit = wire('modules')->get("InputfieldSubmit");
$submit->attr("id+name",'submit');
$submit->attr("class", 'form__button');
$submit->attr("value","Termin anfragen");
$submit->skipLabel = Inputfield::skipLabelBlank;
$form->append($submit);
// HTML structure
$form->setMarkup(array(
'list' => "{out}",
'item' => "<div {attrs}>{out}</div>",
'item_label' => "<label for='{for}'>{out}</label>",
'item_content' => "{out}",
'item_error' => "<div class='formerror'>{out}</div>",
'item_description' => "<div class='description'>{out}</div>",
'item_head' => "<h4>{out}</h4>",
'item_notes' => "<div class='notes'>{out}</div>"
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment