Changeset 5995
- Timestamp:
- 11/13/07 16:50:03 (1 year ago)
- Files:
-
- trunk/lib/widget/sfWidgetFormSchema.class.php (modified) (5 diffs)
- trunk/lib/widget/sfWidgetFormSchemaFormatter.class.php (modified) (4 diffs)
- trunk/lib/widget/sfWidgetFormSchemaFormatterList.class.php (modified) (1 diff)
- trunk/lib/widget/sfWidgetFormSchemaFormatterTable.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/widget/sfWidgetFormSchema.class.php
r5937 r5995 32 32 $labels = array(), 33 33 $fields = array(), 34 $positions = array(); 34 $positions = array(), 35 $helps = array(); 35 36 36 37 /** … … 51 52 * @param array An array of options 52 53 * @param array An array of HTML labels 54 * @param array An array of help texts 53 55 * 54 56 * @see sfWidgetForm 55 57 */ 56 public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array() )58 public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array()) 57 59 { 58 60 if (is_array($fields)) … … 186 188 * 187 189 * @param string The field name 188 * @param str ginThe label name190 * @param string The label name 189 191 */ 190 192 public function setLabel($name, $value) … … 203 205 { 204 206 return array_key_exists($name, $this->labels) ? $this->labels[$name] : ''; 207 } 208 209 /** 210 * Sets the help texts to render for each field. 211 * 212 * @param array An array of help texts 213 */ 214 public function setHelps($helps) 215 { 216 $this->helps = $helps; 217 } 218 219 /** 220 * Sets the help texts. 221 * 222 * @return array An array of help texts 223 */ 224 public function getHelps() 225 { 226 return $this->helps; 227 } 228 229 /** 230 * Sets a help text. 231 * 232 * @param string The field name 233 * @param string The help text 234 */ 235 public function setHelp($name, $help) 236 { 237 $this->helps[$name] = $help; 238 } 239 240 /** 241 * Gets a text help by field name. 242 * 243 * @param string The field name 244 * 245 * @return string The help text or an empty string if it is not defined 246 */ 247 public function getHelp($name) 248 { 249 return array_key_exists($name, $this->helps) ? $this->helps[$name] : ''; 205 250 } 206 251 … … 309 354 $error = $widget instanceof sfWidgetFormSchema ? array() : $error; 310 355 311 $rows[] = $formFormat->formatRow($label, $field, $error );356 $rows[] = $formFormat->formatRow($label, $field, $error, $this->getHelp($name)); 312 357 } 313 358 } trunk/lib/widget/sfWidgetFormSchemaFormatter.class.php
r5937 r5995 10 10 11 11 /** 12 * 12 * sfWidgetFormSchemaFormatter allows to format a form schema with HTML formats. 13 13 * 14 14 * @package symfony … … 21 21 protected 22 22 $rowFormat = '', 23 $helpFormat = '%help%', 23 24 $errorRowFormat = '', 24 25 $errorListFormatInARow = " <ul class=\"error_list\">\n%errors% </ul>\n", … … 33 34 '%field%' => $field, 34 35 '%error%' => $this->formatErrorsForRow($errors), 35 '%help%' => $ help,36 '%help%' => $this->formatHelp($help), 36 37 '%hidden_fields%' => is_null($hiddenFields) ? '%hidden_fields%' : $hiddenFields, 37 38 )); 39 } 40 41 public function formatHelp($help) 42 { 43 if (!$help) 44 { 45 return ''; 46 } 47 48 return strtr($this->getHelpFormat(), array('%help%' => $help)); 38 49 } 39 50 … … 150 161 return $this->decoratorFormat; 151 162 } 163 164 public function setHelpFormat($format) 165 { 166 $this->helpFormat = $format; 167 } 168 169 public function getHelpFormat() 170 { 171 return $this->helpFormat; 172 } 152 173 } trunk/lib/widget/sfWidgetFormSchemaFormatterList.class.php
r5937 r5995 22 22 $rowFormat = "<li>\n %error%%label%\n %field%%help%\n%hidden_fields%</li>\n", 23 23 $errorRowFormat = "<li>\n%errors%</li>\n", 24 $helpFormat = '<br />%help%', 24 25 $decoratorFormat = "<ul>\n %content%</ul>"; 25 26 } trunk/lib/widget/sfWidgetFormSchemaFormatterTable.class.php
r5937 r5995 22 22 $rowFormat = "<tr>\n <th>%label%</th>\n <td>%error%%field%%help%%hidden_fields%</td>\n</tr>\n", 23 23 $errorRowFormat = "<tr><td colspan=\"2\">\n%errors%</td></tr>\n", 24 $helpFormat = '<br />%help%', 24 25 $decoratorFormat = "<table>\n %content%</table>"; 25 26 }