root/trunk/modules/forge/libraries/Form_Group.php

Revision 2539, 1.5 kB (checked in by PugFish, 3 months ago)

Really fixing it this time, doh

  • Property svn:eol-style set to LF
  • Property copyright set to Copyright (c) 2007-2008 Kohana Team
  • Property svn:keywords set to Id
Line 
1 <?php defined('SYSPATH') or die('No direct script access.');
2 /**
3  * FORGE group library.
4  *
5  * $Id$
6  *
7  * @package    Forge
8  * @author     Kohana Team
9  * @copyright  (c) 2007-2008 Kohana Team
10  * @license    http://kohanaphp.com/license.html
11  */
12 class Form_Group_Core extends Forge {
13
14     protected $data = array
15     (
16         'type'  => 'group',
17         'name'  => '',
18         'class' => 'group',
19         'label' => '',
20         'message' => ''
21     );
22
23     // Input method
24     public $method;
25
26     public function __construct($name = NULL, $class = 'group')
27     {
28         $this->data['name'] = $name;
29         $this->data['class'] = $class;
30
31         // Set dummy data so we don't get errors
32         $this->attr['action'] = '';
33         $this->attr['method'] = 'post';
34     }
35
36     public function __get($key)
37     {
38         if ($key == 'type' || $key == 'name')
39         {
40             return $this->data[$key];
41         }
42         return parent::__get($key);
43     }
44
45     public function __set($key, $val)
46     {
47         if ($key == 'method')
48         {
49             $this->attr['method'] = $val;
50         }
51         $this->$key = $val;
52     }
53
54     public function label($val = NULL)
55     {
56         if ($val === NULL)
57         {
58             if ($label = $this->data['label'])
59             {
60                 return $this->data['label'];
61             }
62         }
63         else
64         {
65             $this->data['label'] = ($val === TRUE) ? ucwords(inflector::humanize($this->data['name'])) : $val;
66             return $this;
67         }
68     }
69
70     public function message($val = NULL)
71     {
72         if ($val === NULL)
73         {
74             return $this->data['message'];
75         }
76         else
77         {
78             $this->data['message'] = $val;
79             return $this;
80         }
81     }
82
83     public function render()
84     {
85         // No Sir, we don't want any html today thank you
86         return;
87     }
88
89 } // End Form Group
Note: See TracBrowser for help on using the browser.