ฟอร์มข้อมูล
Code
ผลลัพธ์
Code
<?php
require_once('public/generate-form-dev.php');
$form=new Form();
// ตัวอย่างการสร้างช่องลิสต์
$field['f1']=[
'label'=>'List',
'list'=>[1=>'ตัวเลือก 1',2=>'ตัวเลือก 2'],
'value'=>1,
];
// ตัวอย่างการสร้างช่องลิสต์แบบต่อเนื่อง
$field['f2']=[
'label'=>'List',
'type'=>'list_table',
'list'=>[['1',"หัวข้อ 1"],['2',"หัวข้อ 2"],['3',"หัวข้อ 3"]],
'value'=>'2',
'next'=>'f3',
];
$field['f3']=[
'label'=>'List',
'type'=>'list_table',
'list'=>[['1.1',"หัวข้อ 1.1",'1'],['1.2',"หัวข้อ 1.2",'1'],['2.1',"หัวข้อ 2.1",'2'],['3.1',"หัวข้อ 3.1",'3']],
'value'=>'2.1',
];
$field['f4']=[
'label'=>'List',
'type'=>'list_table',
'command'=>"SELECT `changwatcode`, `changwatname` FROM `cchangwat`",
'value'=>'90',
'next'=>'f5',
'next_command'=>"SELECT `ampurcode`, `ampurname`, `changwatcode` FROM `campur` WHERE changwatcode='{f4}'",
];
$field['f5']=[
'label'=>'List',
'type'=>'list_table',
'value'=>'09',
'next'=>'f6',
'next_command'=>"SELECT `tamboncode`, `tambonname` FROM `ctambon` WHERE changwatcode='{f4}' and ampurcode='{f5}';",
];
$field['f6']=[
'label'=>'List',
'type'=>'list_table',
'value'=>'09',
];
$form->addField($field);
$form->addObject(['type'=>'submit','value'=>'เพิ่มข้อมูล'],['type'=>'back']);
echo $form->create();