Development

/branches/1.3/lib/widget/sfWidgetFormSchemaDecorator.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/widget/sfWidgetFormSchemaDecorator.class.php

Revision 30762, 6.6 kB (checked in by fabien, 4 years ago)

[1.3, 1.4] fixed phpdoc (closes #8931)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfWidgetFormSchemaDecorator wraps a form schema widget inside a given HTML snippet.
13  *
14  * @package    symfony
15  * @subpackage widget
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfWidgetFormSchemaDecorator extends sfWidgetFormSchema
20 {
21   protected
22     $widget    = null,
23     $decorator = '';
24
25   /**
26    * Constructor.
27    *
28    * @param sfWidgetFormSchema $widget     A sfWidgetFormSchema instance
29    * @param string             $decorator  A decorator string
30    *
31    * @see sfWidgetFormSchema
32    */
33   public function __construct(sfWidgetFormSchema $widget, $decorator)
34   {
35     $this->widget    = $widget;
36     $this->decorator = $decorator;
37
38     parent::__construct();
39   }
40
41   /**
42    * Returns the decorated widget.
43    *
44    * @param sfWidget The decorated widget
45    */
46   public function getWidget()
47   {
48     return $this->widget;
49   }
50
51   /**
52    * Renders the widget.
53    *
54    * @param  string $name        The element name
55    * @param  string $values      The value displayed in this widget
56    * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
57    * @param  array  $errors      An array of errors for the field
58    *
59    * @see sfWidget
60    */
61   public function render($name, $values = array(), $attributes = array(), $errors = array())
62   {
63     return strtr($this->decorator, array('%content%' => $this->widget->render($name, $values, $attributes, $errors)));
64   }
65
66   /**
67    * @see sfWidgetFormSchema
68    */
69   public function addFormFormatter($name, sfWidgetFormSchemaFormatter $formatter)
70   {
71     $this->widget->addFormFormatter($name, $formatter);
72
73     return $this;
74   }
75
76   /**
77    * @see sfWidgetFormSchema
78    */
79   public function getFormFormatters()
80   {
81     return $this->widget->getFormFormatters();
82   }
83
84   /**
85    * @see sfWidgetFormSchema
86    */
87   public function setFormFormatterName($name)
88   {
89     $this->widget->setFormFormatterName($name);
90
91     return $this;
92   }
93
94   /**
95    * @see sfWidgetFormSchema
96    */
97   public function getFormFormatterName()
98   {
99     return $this->widget->getFormFormatterName();
100   }
101
102   /**
103    * @see sfWidgetFormSchema
104    */
105   public function getFormFormatter()
106   {
107     return $this->widget->getFormFormatter();
108   }
109
110   /**
111    * @see sfWidgetFormSchema
112    */
113   public function setNameFormat($format)
114   {
115     $this->widget->setNameFormat($format);
116
117     return $this;
118   }
119
120   /**
121    * @see sfWidgetFormSchema
122    */
123   public function getNameFormat()
124   {
125     return $this->widget->getNameFormat();
126   }
127
128   /**
129    * @see sfWidgetFormSchema
130    */
131   public function setLabels(array $labels)
132   {
133     $this->widget->setLabels($labels);
134
135     return $this;
136   }
137
138   /**
139    * @see sfWidgetFormSchema
140    */
141   public function getLabels()
142   {
143     return $this->widget->getLabels();
144   }
145
146   /**
147    * @see sfWidgetFormSchema
148    */
149   public function setLabel($name, $value = null)
150   {
151     if (2 == func_num_args())
152     {
153       $this->widget->setLabel($name, $value);
154     }
155     else
156     {
157       $this->widget->setLabel($name);
158     }
159
160     return $this;
161   }
162
163   /**
164    * @see sfWidgetFormSchema
165    */
166   public function getLabel($name = null)
167   {
168     return 1 == func_num_args() ? $this->widget->getLabel($name) : $this->widget->getLabel();
169   }
170
171   /**
172    * @see sfWidgetFormSchema
173    */
174   public function setHelps(array $helps)
175   {
176     $this->widget->setHelps($helps);
177
178     return $this;
179   }
180
181   /**
182    * @see sfWidgetFormSchema
183    */
184   public function getHelps()
185   {
186     return $this->widget->getHelps();
187   }
188
189   /**
190    * @see sfWidgetFormSchema
191    */
192   public function setHelp($name, $help)
193   {
194     $this->widget->setHelp($name, $help);
195
196     return $this;
197   }
198
199   /**
200    * @see sfWidgetFormSchema
201    */
202   public function getHelp($name)
203   {
204     return $this->widget->getHelp($name);
205   }
206
207   /**
208    * Gets the stylesheet paths associated with the widget.
209    *
210    * @return array An array of stylesheet paths
211    */
212   public function getStylesheets()
213   {
214     return $this->widget->getStylesheets();
215   }
216
217   /**
218    * Gets the JavaScript paths associated with the widget.
219    *
220    * @return array An array of JavaScript paths
221    */
222   public function getJavaScripts()
223   {
224     return $this->widget->getJavaScripts();
225   }
226
227   /**
228    * @see sfWidgetFormSchema
229    */
230   public function needsMultipartForm()
231   {
232     return $this->widget->needsMultipartForm();
233   }
234
235   /**
236    * @see sfWidgetFormSchema
237    */
238   public function renderField($name, $value = null, $attributes = array(), $errors = array())
239   {
240     return $this->widget->renderField($name, $value, $attributes, $errors);
241   }
242
243   /**
244    * @see sfWidgetFormSchemaFormatter
245    */
246   public function generateLabel($name)
247   {
248     return $this->widget->getFormFormatter()->generateLabel($name);
249   }
250
251   /**
252    * @see sfWidgetFormSchemaFormatter
253    */
254   public function generateLabelName($name)
255   {
256     return $this->widget->getFormFormatter()->generateLabelName($name);
257   }
258
259   /**
260    * @see sfWidgetFormSchema
261    */
262   public function generateName($name)
263   {
264     return $this->widget->generateName($name);
265   }
266
267   /**
268    * @see sfWidgetFormSchema
269    */
270   public function getParent()
271   {
272     return $this->widget->getParent();
273   }
274
275   /**
276    * @see sfWidgetFormSchema
277    */
278   public function setParent(sfWidgetFormSchema $parent = null)
279   {
280     $this->widget->setParent($parent);
281
282     return $this;
283   }
284
285   /**
286    * @see sfWidgetFormSchema
287    */
288   public function getFields()
289   {
290     return $this->widget->getFields();
291   }
292
293   /**
294    * @see sfWidgetFormSchema
295    */
296   public function getPositions()
297   {
298     return $this->widget->getPositions();
299   }
300
301   /**
302    * @see sfWidgetFormSchema
303    */
304   public function setPositions(array $positions)
305   {
306     $this->widget->setPositions($positions);
307
308     return $this;
309   }
310
311   /**
312    * @see sfWidgetFormSchema
313    */
314   public function moveField($field, $action, $pivot = null)
315   {
316     return $this->widget->moveField($field, $action, $pivot);
317   }
318
319   /**
320    * @see sfWidgetFormSchema
321    */
322   public function offsetExists($name)
323   {
324     return isset($this->widget[$name]);
325   }
326
327   /**
328    * @see sfWidgetFormSchema
329    */
330   public function offsetGet($name)
331   {
332     return $this->widget[$name];
333   }
334
335   /**
336    * @see sfWidgetFormSchema
337    */
338   public function offsetSet($name, $widget)
339   {
340     $this->widget[$name] = $widget;
341   }
342
343   /**
344    * @see sfWidgetFormSchema
345    */
346   public function offsetUnset($name)
347   {
348     unset($this->widget[$name]);
349   }
350
351   public function __clone()
352   {
353     $this->widget = clone $this->widget;
354   }
355 }
356
Note: See TracBrowser for help on using the browser.