Home > Backend Development > PHP Tutorial > A custom form implementation in php without adding fields_PHP tutorial

A custom form implementation in php without adding fields_PHP tutorial

WBOY
Release: 2016-07-13 17:54:35
Original
1608 people have browsed it

Many open source program systems have custom form functions, such as DreamWeaver and Empire; their custom form creates a new table, which is an implementation method, but sometimes we may need some attachments content, or we don’t need to build multiple tables, we just want to use one field to store the content we append. At this time, we can achieve it through the following implementation method.

Let’s take a look at the implementation first:

A custom form implementation in php without adding fields_PHP tutorial

We can set its prompt text, fields, types, default values, parameters, sorting, and whether to display in the list. Of course, we can also add some similar display methods, whether to highlight them, etc. Its types include text, drop-down, radio selection, check selection, multi-line text and other types. Take a look at the table structure:

A custom form implementation in php without adding fields_PHP tutorial

Needless to say Id, name is the form prompt text, that is, name, gender, etc. qian and ziduan are used in combination. In order to make it easy to distinguish, it is easier to use a prefix and field to form a custom field label. To distinguish, type is the type, value is the default value, and whcs is the parameter. This parameter only works when the type is text or multi-line text by default. When it comes to text, the first parameter limits the maximum number of bytes, and the second parameter limits the length. Role is sorting, yesno is whether to display in the foreground.

A custom form implementation in php without adding fields_PHP tutorial

There is no need to go into details about the code. Setting up this custom form is relatively simple, just traverse it and combine it according to its type.

A custom form implementation in php without adding fields_PHP tutorial

Let me show you the code of this place.

[php] view plaincopyprint? //Get parameter configuration information
$system = $this->tmp_mod->getAllSystem();
if($system){
foreach($system as $key=>$val){
if($val['name']&&$val['ziduan']){
$zhu = '';
if($val['value']){
$value = @explode(',',$val['value']);
}
if($val['whcs']){
$whcs = @explode('$',$val['whcs']);
}
if(2==$val['type']){
$zhu = '';
}elseif(3==$val['type']){
foreach($value as $k=>$v){
$check='';
if('0'==$k){
$check = 'checked';
}
$zhu .=''.$v;
}
}elseif(4==$val['type']){

foreach($value as $m=>$n){
$zhu .=' '.$n;
}
}

$biao[$key]['name'] = $val['name'];
switch ($val['type']){
case '1':$biao[$key]['value']=' maxlength="'.$whcs[0].'" style="width:'.$whcs[1].'px" value="'.$val['value'].'" />';break ;
case '2':$biao[$key]['value']=$zhu;break;
case '3':$biao[$key]['value']=$zhu;break;
case '4':$biao[$key]['value']=$zhu;break;
case 5:$biao[$key]['value']='';break;
default:;
}
}
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477940.htmlTechArticleMany open source program systems have custom form functions, such as Dreamweaver and Empire; their custom forms are Created a new table, this is one way to achieve it, but sometimes I...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template