php Processwire API表单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Processwire API表单相关的知识,希望对你有一定的参考价值。
<?php
/**
* No Fieldset
*
*/
// Build form
$form = $this->modules->get("InputfieldForm");
$form->action = "./";
$form->method = "post";
$form->attr("id+name","FORM_ID");
// Fields
$f = $this->modules->get("InputfieldRadios");
$f->attr('name', 'radio_option');
$f->label = 'Radio Options';
$f->options = ["1" => "Yes", "0" => "No"];
$f->required = true;
$f->defaultValue = 1;
$f->optionColumns = 1;
$f->columnWidth = "100%";
// Add ffield to the form (do this for each field)
$form->append($f);
// file
$f = $this->modules->get("InputfieldFile");
$f->attr('name', 'file');
$f->attr('required', '1');
$f->extensions = "zip";
$f->label = "Update Zip";
$form->append($f);
// Submit
$submit = $this->modules->get("InputfieldSubmit");
$submit->attr("value","Anmelden");
$submit->attr("id+name","submit");
$form->append($submit);
return $form->render();
<?php
// Build form
$form = $this->modules->get("InputfieldForm");
$form->action = "./";
$form->method = "post";
$form->attr("id+name","FORM_ID");
// Build fieldset
$fieldset = $this->modules->get('InputfieldFieldset');
$fieldset->label = 'Fieldset';
// Fields
$f = $this->modules->get("InputfieldRadios");
$f->attr('name', 'radio_option');
$f->label = 'Radio Options';
$f->options = ["1" => "Yes", "0" => "No"];
$f->required = true;
$f->defaultValue = 1;
$f->optionColumns = 1;
$f->columnWidth = "100%";
// Add field to fieldset (do this after each field)
$fieldset->append($f);
// Add fieldset to the form
$form->append($fieldset);
// Submit
$submit = $this->modules->get("InputfieldSubmit");
$submit->attr("value","Anmelden");
$submit->attr("id+name","submit");
// add submit button to the form not fieldset
$form->append($submit);
// return form
return $form->render();
以上是关于php Processwire API表单的主要内容,如果未能解决你的问题,请参考以下文章
php Processwire Find Pages API
php Processwire Pages使用API排序
php Processwire Modules API
php Processwire使用API创建和操作页面,模板,字段,用户等。
php Processwire clean-files.php
php ProcessWire Mail