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:
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:
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.
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.
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:;
}
}
}
}