Overview

Namespaces

  • Kotchasan
    • Cache
    • Database
    • Http
    • Log
    • Orm
  • None
  • PHP
  • Psr
    • Cache
    • Http
      • Message
    • Log

Classes

  • ArrayIterator
  • DateInterval
  • DOMNode
  • Kotchasan
  • Kotchasan\Accordion
  • Kotchasan\ApiController
  • Kotchasan\ArrayTool
  • Kotchasan\Cache\ApcCache
  • Kotchasan\Cache\Cache
  • Kotchasan\Cache\CacheItem
  • Kotchasan\Cache\FileCache
  • Kotchasan\CKEditor
  • Kotchasan\Collection
  • Kotchasan\Config
  • Kotchasan\Controller
  • Kotchasan\Country
  • Kotchasan\Csv
  • Kotchasan\Curl
  • Kotchasan\Currency
  • Kotchasan\Database
  • Kotchasan\Database\Db
  • Kotchasan\Database\DbCache
  • Kotchasan\Database\Driver
  • Kotchasan\Database\PdoMysqlDriver
  • Kotchasan\Database\Query
  • Kotchasan\Database\QueryBuilder
  • Kotchasan\Database\Schema
  • Kotchasan\Database\Sql
  • Kotchasan\DataTable
  • Kotchasan\Date
  • Kotchasan\DOMNode
  • Kotchasan\DOMParser
  • Kotchasan\Email
  • Kotchasan\File
  • Kotchasan\Files
  • Kotchasan\Form
  • Kotchasan\Grid
  • Kotchasan\Html
  • Kotchasan\Htmldoc
  • Kotchasan\HtmlTable
  • Kotchasan\Http\AbstractMessage
  • Kotchasan\Http\AbstractRequest
  • Kotchasan\Http\Message
  • Kotchasan\Http\NotFound
  • Kotchasan\Http\Request
  • Kotchasan\Http\Response
  • Kotchasan\Http\Stream
  • Kotchasan\Http\UploadedFile
  • Kotchasan\Http\Uri
  • Kotchasan\Image
  • Kotchasan\InputItem
  • Kotchasan\Inputs
  • Kotchasan\KBase
  • Kotchasan\Language
  • Kotchasan\ListItem
  • Kotchasan\Log\AbstractLogger
  • Kotchasan\Log\Logger
  • Kotchasan\Login
  • Kotchasan\Menu
  • Kotchasan\Mime
  • Kotchasan\Model
  • Kotchasan\Number
  • Kotchasan\ObjectTool
  • Kotchasan\Orm\Field
  • Kotchasan\Orm\Recordset
  • Kotchasan\Password
  • Kotchasan\Pdf
  • Kotchasan\Province
  • Kotchasan\Router
  • Kotchasan\Session
  • Kotchasan\Singleton
  • Kotchasan\Tab
  • Kotchasan\TableRow
  • Kotchasan\Template
  • Kotchasan\Text
  • Kotchasan\Validator
  • Kotchasan\View
  • PHPMailer
  • Psr\Log\AbstractLogger
  • Psr\Log\LogLevel
  • Psr\Log\NullLogger
  • SMTP

Interfaces

  • ArrayAccess
  • Countable
  • DateTimeInterface
  • Iterator
  • IteratorAggregate
  • Psr\Cache\CacheItemInterface
  • Psr\Cache\CacheItemPoolInterface
  • Psr\Http\Message\MessageInterface
  • Psr\Http\Message\RequestInterface
  • Psr\Http\Message\ResponseInterface
  • Psr\Http\Message\ServerRequestInterface
  • Psr\Http\Message\StreamInterface
  • Psr\Http\Message\UploadedFileInterface
  • Psr\Http\Message\UriInterface
  • Psr\Log\LoggerAwareInterface
  • Psr\Log\LoggerInterface
  • SeekableIterator
  • Serializable
  • Traversable

Traits

  • Psr\Log\LoggerTrait

Exceptions

  • Exception
  • InvalidArgumentException
  • Kotchasan\ApiException
  • Kotchasan\Cache\Exception
  • Kotchasan\Database\Exception
  • Kotchasan\InputItemException
  • LogicException
  • phpmailerException
  • RuntimeException

Functions

  • createClass
  • debug
  • getClassPath
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * @filesource Kotchasan/Form.php
  4:  *
  5:  * @copyright 2016 Goragod.com
  6:  * @license http://www.kotchasan.com/license/
  7:  *
  8:  * @see http://www.kotchasan.com/
  9:  */
 10: 
 11: namespace Kotchasan;
 12: 
 13: /**
 14:  * Form class
 15:  *
 16:  * @author Goragod Wiriya <admin@goragod.com>
 17:  *
 18:  * @since 1.0
 19:  */
 20: class Form extends \Kotchasan\KBase
 21: {
 22:     /**
 23:      * ตับแปรบอกว่ามีการใช้ form แบบ Ajax หรือไม่
 24:      * ถ้าใช้งานต้องมีการเรียกใช้ GAjax ด้วย
 25:      *
 26:      * @var bool
 27:      */
 28:     public $ajax;
 29:     /**
 30:      * ตัวแปรบอกว่ามีการใช้งานฟอร์มร่วมกับ GForm หรือไม่
 31:      * ถ้าใช้งานต้องมีการเรียกใช้ GAjax ด้วย.
 32:      *
 33:      * @var bool
 34:      */
 35:     public $gform;
 36:     /**
 37:      * Javascript
 38:      *
 39:      * @var string
 40:      */
 41:     public $javascript;
 42:     /**
 43:      * tag attributes
 44:      *
 45:      * @var array
 46:      */
 47:     private $attributes;
 48:     /**
 49:      * ชื่อ tag
 50:      *
 51:      * @var string
 52:      */
 53:     private $tag;
 54: 
 55:     /**
 56:      * @param array $attributes
 57:      *
 58:      * @return \static
 59:      */
 60:     public static function button($attributes = array())
 61:     {
 62:         $obj = new static();
 63:         if (isset($attributes['tag']) && $attributes['tag'] == 'input') {
 64:             $obj->tag = 'input';
 65:         } else {
 66:             $obj->tag = 'button';
 67:         }
 68:         unset($attributes['tag']);
 69:         $attributes['type'] = 'button';
 70:         $obj->attributes = $attributes;
 71:         return $obj;
 72:     }
 73: 
 74:     /**
 75:      * @param array $attributes
 76:      *
 77:      * @return \static
 78:      */
 79:     public static function checkbox($attributes = array())
 80:     {
 81:         $obj = new static();
 82:         $obj->tag = 'input';
 83:         $attributes['type'] = 'checkbox';
 84:         $obj->attributes = $attributes;
 85:         return $obj;
 86:     }
 87: 
 88:     /**
 89:      * @param array $attributes
 90:      *
 91:      * @return \static
 92:      */
 93:     public static function color($attributes = array())
 94:     {
 95:         $obj = new static();
 96:         $obj->tag = 'input';
 97:         $attributes['type'] = 'text';
 98:         $attributes['class'] = 'color';
 99:         $obj->attributes = $attributes;
100:         return $obj;
101:     }
102: 
103:     /**
104:      * @param array $attributes
105:      *
106:      * @return \static
107:      */
108:     public static function currency($attributes = array())
109:     {
110:         $obj = new static();
111:         $obj->tag = 'input';
112:         $attributes['type'] = 'text';
113:         $attributes['class'] = 'currency';
114:         $obj->attributes = $attributes;
115:         return $obj;
116:     }
117: 
118:     /**
119:      * @param array $attributes
120:      *
121:      * @return \static
122:      */
123:     public static function date($attributes = array())
124:     {
125:         $obj = new static();
126:         $obj->tag = 'input';
127:         $attributes['type'] = 'date';
128:         $obj->attributes = $attributes;
129:         return $obj;
130:     }
131: 
132:     /**
133:      * @param array $attributes
134:      *
135:      * @return \static
136:      */
137:     public static function email($attributes = array())
138:     {
139:         $obj = new static();
140:         $obj->tag = 'input';
141:         $attributes['type'] = 'email';
142:         $obj->attributes = $attributes;
143: 
144:         return $obj;
145:     }
146: 
147:     /**
148:      * @param array $attributes
149:      *
150:      * @return \static
151:      */
152:     public static function file($attributes = array())
153:     {
154:         $obj = new static();
155:         $obj->tag = 'input';
156:         $attributes['type'] = 'file';
157:         $attributes['class'] = 'g-file';
158:         $obj->attributes = $attributes;
159:         return $obj;
160:     }
161: 
162:     /**
163:      * ฟังก์ชั่นสร้าง input ชนิด hidden สำหรับใช้ในฟอร์ม
164:      * ใช้ประโยชน์ในการสร้าง URL เพื่อส่งกลับไปยังหน้าเดิมหลังจาก submit แล้ว.
165:      *
166:      * @return array
167:      */
168:     public static function get2Input()
169:     {
170:         $hiddens = array();
171:         foreach (self::$request->getQueryParams() as $key => $value) {
172:             if ($value != '' && !preg_match('/.*?(username|password|token|time).*?/', $key) && preg_match('/^[_]+([^0-9]+)$/', $key, $match)) {
173:                 $hiddens[$match[1]] = '<input type="hidden" name="_'.$match[1].'" value="'.htmlspecialchars($value).'">';
174:             }
175:         }
176:         foreach (self::$request->getParsedBody() as $key => $value) {
177:             if ($value != '' && !preg_match('/.*?(username|password|token|time).*?/', $key) && preg_match('/^[_]+([^0-9]+)$/', $key, $match)) {
178:                 $hiddens[$match[1]] = '<input type="hidden" name="_'.$match[1].'" value="'.htmlspecialchars($value).'">';
179:             }
180:         }
181:         return $hiddens;
182:     }
183: 
184:     /**
185:      * @param array $attributes
186:      *
187:      * @return \static
188:      */
189:     public static function hidden($attributes = array())
190:     {
191:         $obj = new static();
192:         $obj->tag = 'input';
193:         $attributes['type'] = 'hidden';
194:         $obj->attributes = $attributes;
195:         return $obj;
196:     }
197: 
198:     /**
199:      * @param array $attributes
200:      *
201:      * @return \static
202:      */
203:     public static function number($attributes = array())
204:     {
205:         $obj = new static();
206:         $obj->tag = 'input';
207:         $attributes['type'] = 'number';
208:         $obj->attributes = $attributes;
209:         return $obj;
210:     }
211: 
212:     /**
213:      * @param array $attributes
214:      *
215:      * @return \static
216:      */
217:     public static function integer($attributes = array())
218:     {
219:         $obj = new static();
220:         $obj->tag = 'input';
221:         $attributes['type'] = 'integer';
222:         $obj->attributes = $attributes;
223:         return $obj;
224:     }
225: 
226:     /**
227:      * @param array $attributes
228:      *
229:      * @return \static
230:      */
231:     public static function password($attributes = array())
232:     {
233:         $obj = new static();
234:         $obj->tag = 'input';
235:         $attributes['type'] = 'password';
236:         $obj->attributes = $attributes;
237:         return $obj;
238:     }
239: 
240:     /**
241:      * @param array $attributes
242:      *
243:      * @return \static
244:      */
245:     public static function radio($attributes = array())
246:     {
247:         $obj = new static();
248:         $obj->tag = 'input';
249:         $attributes['type'] = 'radio';
250:         $obj->attributes = $attributes;
251:         return $obj;
252:     }
253: 
254:     /**
255:      * @param array $attributes
256:      *
257:      * @return \static
258:      */
259:     public static function range($attributes = array())
260:     {
261:         $obj = new static();
262:         $obj->tag = 'input';
263:         $attributes['type'] = 'range';
264:         $obj->attributes = $attributes;
265:         return $obj;
266:     }
267: 
268:     /**
269:      * ฟังก์ชั่นสร้าง Form Element.
270:      * id, name, type property ต่างๆของinput
271:      * label : ข้อความแสดงใน label ของ input
272:      * labelClass : class ของ label
273:      * comment : ถ้ากำหนดจะแสดงคำอธิบายของ input
274:      * ถ้าไม่กำหนดทั้ง label และ labelClass จะเป็นการสร้าง input อย่างเดียว
275:      * array('name1' => 'value1', 'name2' => 'value2', ....)
276:      *
277:      * @param string $tag
278:      * @param array  $param   property ของ Input
279:      * @param string $options ตัวเลือก options ของ select
280:      *
281:      * @return string
282:      */
283:     public function render()
284:     {
285:         $prop = array();
286:         $event = array();
287:         foreach ($this->attributes as $k => $v) {
288:             switch ($k) {
289:                 case 'itemClass':
290:                 case 'itemId':
291:                 case 'labelClass':
292:                 case 'label':
293:                 case 'comment':
294:                 case 'unit':
295:                 case 'value':
296:                 case 'dataPreview':
297:                 case 'previewSrc':
298:                 case 'accept':
299:                 case 'options':
300:                 case 'optgroup':
301:                 case 'multiple':
302:                 case 'validator':
303:                 case 'result':
304:                 case 'checked':
305:                 case 'datalist':
306:                 case 'button':
307:                     $$k = $v;
308:                     break;
309:                 case 'title':
310:                     $prop['title'] = 'title="'.strip_tags($v).'"';
311:                     break;
312:                 default:
313:                     if ($k == 'id') {
314:                         $id = $v;
315:                     } elseif (is_int($k)) {
316:                         $prop[$v] = $v;
317:                     } elseif ($v === true) {
318:                         $prop[$k] = $k;
319:                     } elseif ($v === false) {
320:                     } elseif (preg_match('/^on([a-z]+)/', $k, $match)) {
321:                         $event[$match[1]] = $v;
322:                     } elseif (!is_array($v)) {
323:                         $prop[$k] = $k.'="'.$v.'"';
324:                         $$k = $v;
325:                     }
326:                     break;
327:             }
328:         }
329:         if (isset($id)) {
330:             if (empty($name)) {
331:                 $name = $id;
332:                 $prop['name'] = 'name="'.$name.'"';
333:             }
334:             $id = trim(preg_replace('/[\[\]]+/', '_', $id), '_');
335:             $prop['id'] = 'id="'.$id.'"';
336:         }
337:         if (isset(Html::$form)) {
338:             if (isset($id) && Html::$form->gform) {
339:                 if (isset($validator)) {
340:                     $js = array();
341:                     $js[] = '"'.$id.'"';
342:                     $js[] = '"'.$validator[0].'"';
343:                     $js[] = $validator[1];
344:                     if (isset($validator[2])) {
345:                         $js[] = '"'.$validator[2].'"';
346:                         $js[] = empty($validator[3]) || $validator[3] === null ? 'null' : '"'.$validator[3].'"';
347:                         $js[] = '"'.Html::$form->attributes['id'].'"';
348:                     }
349:                     $this->javascript[] = 'new GValidator('.implode(', ', $js).');';
350:                     unset($validator);
351:                 }
352:                 foreach ($event as $on => $func) {
353:                     $this->javascript[] = '$G("'.$id.'").addEvent("'.$on.'", '.$func.');';
354:                 }
355:             } elseif (!Html::$form->gform) {
356:                 foreach ($event as $on => $func) {
357:                     $prop['on'.$on] = 'on'.$on.'="'.$func.'()"';
358:                 }
359:             }
360:         }
361:         if ($this->tag == 'select') {
362:             unset($prop['type']);
363:             if (isset($multiple)) {
364:                 $value = isset($value) ? $value : array();
365:             } else {
366:                 $value = isset($value) ? $value : null;
367:             }
368:             if (isset($options) && is_array($options)) {
369:                 $datas = array();
370:                 foreach ($options as $k => $v) {
371:                     if (is_array($value)) {
372:                         $sel = in_array($k, $value) ? ' selected' : '';
373:                     } else {
374:                         $sel = $value == $k ? ' selected' : '';
375:                     }
376:                     if (is_int($k)) {
377:                         $datas[] = '<option value='.$k.$sel.'>'.$v.'</option>';
378:                     } else {
379:                         $datas[] = '<option value="'.$k.'"'.$sel.'>'.$v.'</option>';
380:                     }
381:                 }
382:                 $value = implode('', $datas);
383:             } elseif (isset($optgroup) && is_array($optgroup)) {
384:                 $datas = array();
385:                 foreach ($optgroup as $group_label => $options) {
386:                     $datas[] = '<optgroup label="'.$group_label.'">';
387:                     foreach ($options as $k => $v) {
388:                         if (is_array($value)) {
389:                             $sel = in_array($k, $value) ? ' selected' : '';
390:                         } else {
391:                             $sel = $value == $k ? ' selected' : '';
392:                         }
393:                         $datas[] = '<option value="'.$k.'"'.$sel.'>'.$v.'</option>';
394:                     }
395:                     $datas[] = '</optgroup>';
396:                 }
397:                 $value = implode('', $datas);
398:             }
399:         } elseif (isset($value)) {
400:             if ($this->tag === 'textarea') {
401:                 $value = str_replace(array('{', '}', '&amp;'), array('&#x007B;', '&#x007D;', '&'), htmlspecialchars($value));
402:             } elseif ($this->tag != 'button') {
403:                 if (is_int($value)) {
404:                     $prop['value'] = 'value='.$value;
405:                 } else {
406:                     $prop['value'] = 'value="'.str_replace('&amp;', '&', htmlspecialchars($value)).'"';
407:                 }
408:             }
409:         }
410:         if (empty($prop['title'])) {
411:             if (!empty($comment)) {
412:                 $prop['title'] = 'title="'.strip_tags($comment).'"';
413:             } elseif (!empty($label)) {
414:                 $prop['title'] = 'title="'.strip_tags($label).'"';
415:             }
416:         }
417:         if (isset($dataPreview)) {
418:             $prop['data-preview'] = 'data-preview="'.$dataPreview.'"';
419:         }
420:         if (isset($result)) {
421:             $prop['data-result'] = 'data-result="result_'.$result.'"';
422:         }
423:         if (isset($accept) && is_array($accept)) {
424:             $prop['accept'] = 'accept="'.Mime::getAccept($accept).'"';
425:         }
426:         if (isset($multiple)) {
427:             $prop['multiple'] = 'multiple';
428:         }
429:         if (isset($checked) && isset($value) && $checked == $value) {
430:             $prop['checked'] = 'checked';
431:         }
432:         if (isset($datalist) && is_array($datalist)) {
433:             if (empty($prop['list'])) {
434:                 $list = $id.'-datalist';
435:             } else {
436:                 $list = $prop['list'];
437:             }
438:             $prop['list'] = 'list="'.$list.'"';
439:             $prop['autocomplete'] = 'autocomplete="off"';
440:         }
441:         $prop = implode(' ', $prop);
442:         if ($this->tag == 'input') {
443:             $element = '<'.$this->tag.' '.$prop.'>';
444:         } elseif (isset($value)) {
445:             $element = '<'.$this->tag.' '.$prop.'>'.$value.'</'.$this->tag.'>';
446:         } else {
447:             $element = '<'.$this->tag.' '.$prop.'></'.$this->tag.'>';
448:         }
449:         if (isset($datalist) && is_array($datalist)) {
450:             $element .= '<datalist id="'.$list.'">';
451:             foreach ($datalist as $k => $v) {
452:                 if (is_int($k)) {
453:                     $element .= '<option value='.$k.'>'.$v.'</option>';
454:                 } else {
455:                     $element .= '<option value="'.$k.'">'.$v.'</option>';
456:                 }
457:             }
458:             $element .= '</datalist>';
459:         }
460:         if (empty($itemClass)) {
461:             $input = empty($comment) ? '' : '<div class="item"'.(empty($itemId) ? '' : ' id="'.$itemId.'"').'>';
462:             $input = empty($unit) ? '' : '<div class="wlabel">';
463:             if (empty($labelClass) && empty($label)) {
464:                 $input .= $element;
465:             } elseif (isset($type) && ($type === 'checkbox' || $type === 'radio')) {
466:                 if (!empty($button)) {
467:                     $label = '<span>'.$label.'</span>';
468:                 }
469:                 $input .= '<label'.(empty($labelClass) ? '' : ' class="'.$labelClass.'"').'>'.$element.$label.'</label>';
470:             } else {
471:                 $input .= '<label'.(empty($labelClass) ? '' : ' class="'.$labelClass.'"').'>'.(empty($label) ? '' : $label.'&nbsp;').$element.'</label>';
472:             }
473:             if (!empty($unit)) {
474:                 $input .= '<span class="label">'.$unit.'</span></div>';
475:             }
476:             if (!empty($comment)) {
477:                 $input .= '<div class="comment"'.(empty($id) ? '' : ' id="result_'.$id.'"').'>'.$comment.'</div>';
478:             }
479:         } else {
480:             if (!empty($unit)) {
481:                 $itemClass .= ' wlabel';
482:             }
483:             $input = '<div class="'.$itemClass.'"'.(empty($itemId) ? '' : ' id="'.$itemId.'"').'>';
484:             if (isset($type) && $type === 'checkbox') {
485:                 $input .= '<label'.(empty($labelClass) ? '' : ' class="'.$labelClass.'"').'>'.$element.'&nbsp;'.(isset($label) ? $label : '').'</label>';
486:             } else {
487:                 if (isset($dataPreview)) {
488:                     $input .= '<div class="file-preview" id="'.$dataPreview.'">';
489:                     if (isset($previewSrc)) {
490:                         if (preg_match_all('/\.([a-z0-9]+)(\?|$)/i', $previewSrc, $match)) {
491:                             $ext = strtoupper($match[1][0]);
492:                             if (in_array($ext, array('JPG', 'JPEG', 'GIF', 'PNG', 'BMP', 'WEBP', 'TIFF', 'ICO'))) {
493:                                 $input .= '<a href="'.$previewSrc.'" target="preview" class="file-thumb" style="background-image:url('.$previewSrc.')"></a>';
494:                             } else {
495:                                 $input .= '<a href="'.$previewSrc.'" target="preview" class="file-thumb">'.$ext.'</a>';
496:                             }
497:                         }
498:                     }
499:                     $input .= '</div>';
500:                 }
501:                 if (isset($label) && isset($id)) {
502:                     $input .= '<label for="'.$id.'">'.$label.'</label>';
503:                 }
504:                 $input .= '<span'.(empty($labelClass) ? '' : ' class="'.$labelClass.'"').'>'.$element.'</span>';
505:                 if (!empty($unit)) {
506:                     $input .= '<span class=label>'.$unit.'</span>';
507:                 }
508:             }
509:             if (!empty($comment)) {
510:                 $input .= '<div class="comment"'.(empty($id) ? '' : ' id="result_'.$id.'"').'>'.$comment.'</div>';
511:             }
512:             $input .= '</div>';
513:         }
514:         return $input;
515:     }
516: 
517:     /**
518:      * @param array $attributes
519:      *
520:      * @return \static
521:      */
522:     public static function reset($attributes = array())
523:     {
524:         $obj = new static();
525:         if (isset($attributes['tag']) && $attributes['tag'] == 'input') {
526:             $obj->tag = 'input';
527:         } else {
528:             $obj->tag = 'button';
529:         }
530:         unset($attributes['tag']);
531:         $attributes['type'] = 'reset';
532:         if (isset($attributes['name']) && $attributes['name'] == 'reset') {
533:             unset($attributes['name']);
534:         }
535:         if (isset($attributes['id']) && $attributes['id'] == 'reset') {
536:             unset($attributes['id']);
537:         }
538:         $obj->attributes = $attributes;
539:         return $obj;
540:     }
541: 
542:     /**
543:      * @param array $attributes
544:      *
545:      * @return \static
546:      */
547:     public static function select($attributes = array())
548:     {
549:         $obj = new static();
550:         $obj->tag = 'select';
551:         $obj->attributes = $attributes;
552: 
553:         return $obj;
554:     }
555: 
556:     /**
557:      * @param array $attributes
558:      *
559:      * @return \static
560:      */
561:     public static function submit($attributes = array())
562:     {
563:         $obj = new static();
564:         if (isset($attributes['tag']) && $attributes['tag'] == 'input') {
565:             $obj->tag = 'input';
566:         } else {
567:             $obj->tag = 'button';
568:         }
569:         unset($attributes['tag']);
570:         $attributes['type'] = 'submit';
571:         if (isset($attributes['name']) && $attributes['name'] == 'submit') {
572:             unset($attributes['name']);
573:         }
574:         if (isset($attributes['id']) && $attributes['id'] == 'submit') {
575:             unset($attributes['id']);
576:         }
577:         $obj->attributes = $attributes;
578:         return $obj;
579:     }
580: 
581:     /**
582:      * @param array $attributes
583:      *
584:      * @return \static
585:      */
586:     public static function tel($attributes = array())
587:     {
588:         $obj = new static();
589:         $obj->tag = 'input';
590:         $attributes['type'] = 'tel';
591:         $obj->attributes = $attributes;
592:         return $obj;
593:     }
594: 
595:     /**
596:      * สร้าง input, select, textarea สำหรับใส่ลงในฟอร์ม
597:      * id, name, type property ต่างๆของinput
598:      * options สำหรับ select เท่านั้น เช่น array('value1'=> 'name1', 'value2'=>'name2', ...)
599:      * label ข้อความแสดงใน label ของ input
600:      * labelClass class ของ label
601:      * comment ถ้ากำหนดจะแสดงคำอธิบายของ input
602:      * ถ้าไม่กำหนดทั้ง label และ labelClass จะเป็นการสร้าง input อย่างเดียว
603:      *
604:      * @param array $attributes property ของ Input
605:      */
606:     public static function text($attributes = array())
607:     {
608:         $obj = new static();
609:         $obj->tag = 'input';
610:         $attributes['type'] = 'text';
611:         $obj->attributes = $attributes;
612:         return $obj;
613:     }
614: 
615:     /**
616:      * @param array $attributes
617:      *
618:      * @return \static
619:      */
620:     public static function textarea($attributes = array())
621:     {
622:         $obj = new static();
623:         $obj->tag = 'textarea';
624:         $obj->attributes = $attributes;
625:         return $obj;
626:     }
627: 
628:     /**
629:      * @param array $attributes
630:      *
631:      * @return \static
632:      */
633:     public static function time($attributes = array())
634:     {
635:         $obj = new static();
636:         $obj->tag = 'input';
637:         $attributes['type'] = 'time';
638:         $obj->attributes = $attributes;
639:         return $obj;
640:     }
641: 
642:     /**
643:      * @param array $attributes
644:      *
645:      * @return \static
646:      */
647:     public static function url($attributes = array())
648:     {
649:         $obj = new static();
650:         $obj->tag = 'input';
651:         $attributes['type'] = 'url';
652:         $obj->attributes = $attributes;
653:         return $obj;
654:     }
655: }
656: 
Kotchasan API documentation generated by ApiGen