$_setting adapun value dari variable tersebut bisa anda tentukan dengan contoh pilihan di bawahBerikut adalah keterangan mengenai variable
$_setting:
$_setting = array(
'nama_field' => array( // nama field yang akan bisa digunakan pada variable $config di _switch.php
'text' => String, // Judul dari field
'tips' => String, // text yang akan muncul di bawah input field
'add' => String, // text tambahan setelah input field
'help' => String, // text bantuan yang muncul ketika judul field di hover
'type' => String, // Contoh: text|plain|radio|select|checkbox|textarea|file|captcha
'language' => Boolean, // apakah input ini support multilanguage atau tidak
'attr' => String, // text attribute tambahan di dalam HMTL Input
'default' => String|Array, // nilai default sebelum diisi
'mandatory' => Boolean, // Apakah input ini wajib diisi atau tidak
'checked' => String // isian dari user akan di validasi: any|email|url|phone|number (nay=tanpa validasi)
)
);
key/index 'type' wajib digunakan dan diisi sesuai pilihan (text / plain / radio / select / checkbox / textarea / file / captcha), sedangkan untuk key yang lain tidak harus digunakan hanya jika kita merasa membutuhkanContoh File setting yang bisa digunakan
untuk memudahkan proses coding anda bisa meng-copas sample script di bawah kemudian merubah sesuai keperluan anda.
$_setting = array(
'inputtext' => array(
'text' => 'Sample Text Input',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'text', // type of input
'language' => true, // is input support multiple language, default value is false
'attr' => ' size="40"', // additional attribute for the input
'default' => 'insert default value',
'mandatory' => 1, // is this field must be filled in (compulsory). Eg. 1 or 0
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
),
'plain' => array(
'text' => 'Sample Plaintext',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'plain',
'default' => 'this is the text'
),
'radio' => array(
'text' => 'Sample Radio input',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'radio',
'delim' => " -- ",
'option' => array('yes', 'no'),
'default' => '0',
'mandatory' => 1, // is this field must be filled in (compulsory). Eg. 1 or 0
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
),
'select' => array(
'text' => 'Sample Select input',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'select',
'is_arr' => true, // if this is true, user has multiple selection
'option' => array(1 => 'yes', 0 => 'no'),
'default' => 'no',
'mandatory' => 0, // is this field must be filled in (compulsory). Eg. 1 or 0
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
),
'checkbox' => array(
'text' => 'Sample Checkbox input',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'checkbox',
'delim' => " -- ",
'option' => array(1 => 'yes', 0 => 'no'), // leave it empty or unset for one checkbox and value
'default' => 1,
'mandatory' => 0, // is this field must be filled in (compulsory). Eg. 1 or 0
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
),
'checkbox2' => array(
'text' => 'Sample Checkbox with one option',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'checkbox',
'option' => 'activate',
'default' => 1,
'mandatory' => 0, // is this field must be filled in (compulsory). Eg. 1 or 0
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
),
'textarea' => array(
'text' => 'Sample textarea input',
'tips' => 'text to display under the input in small font-size',
'add' => 'additional text after the input',
'help' => 'popup tips to display right after the title',
'type' => 'textarea',
'language' => true, // is input support multiple language, default value is false
'default' => 'sfdghgfhg',// default value
'mandatory' => 0, // is this field must be filled in (compulsory). Eg. 1 or 0
'format' => 'none', // what format you want to use eg. none | code | html
'checked' => 'any' // validate input eg. 'any' / 'email' / 'url' / 'phone' / 'number'
)
);
Penggunaan konfigurasi dalam script di _switch.php
untuk menggunakan konfigurasi di atas dalam script anda cukup menggunakan variable$config diikuti dengan nama field yang ingin anda akses.Dari contoh diatas untuk menampilkan isi dari field dengan nama 'characters' anda cukup
echo $config['characters'];
0 Komentar
Berikan komentar anda