2017 © Pedro Peláez
 

library form

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

image

gclinux/form

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  • Monday, November 20, 2017
  • by gclinux
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

intuition

一个非常简单的php表单输入框生成类,我自己主要是写来解决tp5模版生成表单不友好的问题.当然其他地方都可以用的., (*1)

install:

本类支持composer直接安装, (*2)

composer require gclinux/form

how to use:

$f = new gclinux\form();

$f->input('my-name','Joffe');
//<input name="my-name" class="form-control" id="my-name">

//setAttr will effect the default attr.
$f->setAttr('class'=>'AA')->input('my-name','Joffe');
$f->input('my-name2','Joffe');
//<input name="my-name" class="AA" id="my-name">
//<input name="my-name2" class="AA" id="my-name2">

$f->input('my-name','Joffe','passwd',[class=>'pass','test'=>""]);
//<input name="my-name" class="pass" id="my-name" test="">

$f->select('simple-select',['a','b','c','d'=>'E'],'b');
/**
<select name="simple-select" class="form-control" id="simple-select" >
<option value="a" >a</option>
<option value="b" selected>b</option>
<option value="c" >c</option>
<option value="d" >E</option>
</select>
**/
//group selectd
$f->select('group-select',['group_A'=>['a','b','c'],'group_B'=>['a1'=>'A','b1'=>'B']],'b');
/*
<select name="group-select" class="form-control" id="group-select" >
<optgroup label="group_A">
<option value="a" >a</option>
<option value="b" selected>b</option>
<option value="c" >c</option>
</optgroup>
<optgroup label="group_B">
<option value="a1" >A</option>
<option value="b1" >B</option>
</optgroup>
</select>
*/

//complex select
$f->select('test',
    [
    'test'=>9,
    'group'=>['a'=>'A','b'=>'B','C','D'],
    'E','f'=>'F',
    'number_group'=>['1','CC','NUMC'=>['a9','a10']],
    'ccc'
    ]
    ,'C');
/*
<select name="test" class="form-control" id="test" >
<option value="test" >9</option>
<optgroup label="group">
<option value="a" >A</option>
<option value="b" >B</option>
<option value="C" selected>C</option>
<option value="D" >D</option>
</optgroup>
<option value="E" >E</option>
<option value="f" >F</option>
<optgroup label="number_group">
<option value="1" >1</option>
<option value="CC" >CC</option>
<optgroup label="NUMC">
<option value="a9" >a9</option>
<option value="a10" >a10</option>
</optgroup>
</optgroup>
<option value="ccc" >ccc</option>
</select>
*/

//textarea
$f->textarea('name','the value');

在thinkphp里面使用

安装后 composer require gclinux/form, (*3)

在需要用的模版上 例如 view/index/index.html 里, (*4)

{~$f = new \gclinux\Form()}
{:$f->input('test','')}

The Versions

20/11 2017

dev-master

9999999-dev

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  Sources   Download

MIT

by Avatar gclinux

20/11 2017

1.0.2

1.0.2.0

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  Sources   Download

MIT

by Avatar gclinux

20/11 2017

1.01

1.01.0.0

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  Sources   Download

MIT

by Avatar gclinux

20/11 2017

1.0.1

1.0.1.0

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  Sources   Download

MIT

by Avatar gclinux

10/11 2017

1.0.0

1.0.0.0

使用PHP方便创建一些表单控件,之前用thinkphp太揪心了,特别是遇到select的时候

  Sources   Download

MIT

by Avatar gclinux