Changeset 17084
- Timestamp:
- 04/07/09 14:39:32 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfViewableFormPlugin/trunk/README
r17007 r17084 8 8 forms: 9 9 sfGuardFormSignin: 10 _formatter: mySigninFormFormatter 10 11 username: 11 12 help: Please enter the username you selected during signup. 12 13 _post_validator: 13 14 invalid: The username and password you entered were not recognized. 15 sfGuardUserForm: 16 _formatter: list 14 17 15 18 widgets: … … 21 24 invalid: '"%value%" is not a valid email address.' 22 25 26 formatters: 27 list: myWidgetFormSchemaFormatterList 28 custom: myWidgetFormSchemaFormatterCustom 29 23 30 The effect of this configuration file is just as it appears. Custom error 24 31 messages will be added to the `sfGuardFormSignin` form, the CSS class "text" 25 32 will be added to all instances of `sfWidgetFormInput`, and a custom error 26 message will be added to all instances of `sfValidatorEmail`. 33 message will be added to all instances of `sfValidatorEmail`. The 34 `sfGuardFormSignin` form will use the `mySigninFormFormatter` formatter and 35 `sfGuardUserForm` will use the `myWidgetFormSchemaFormatterList` formatter. 27 36 28 37 ## Model forms plugins/sfViewableFormPlugin/trunk/lib/form/sfViewableForm.class.php
r17080 r17084 154 154 protected function enhanceFormFields(sfFormFieldSchema $fieldSchema, $formClass, array $embeddedForms = array(), $object = null) 155 155 { 156 // enhance schemas 157 $this->enhanceWidget($fieldSchema->getWidget(), $object); 158 if ($fieldSchema->hasError()) 159 { 160 $this->enhanceValidator($fieldSchema->getError()->getValidator(), $object); 161 } 162 156 163 // loop through the fields and apply the global configuration 157 164 foreach ($fieldSchema as $field) … … 200 207 { 201 208 $params = $this->replaceConstants($params, $object); 209 210 if ('_formatter' == $name) 211 { 212 $fieldSchema->getWidget()->setFormFormatterName($params); 213 214 // parameter can be a class name 215 if (class_exists($params) && is_subclass_of($params, 'sfWidgetFormSchemaFormatter')) 216 { 217 $fieldSchema->getWidget()->addFormFormatter($params, new $params($fieldSchema->getWidget())); 218 } 219 220 continue; 221 } 202 222 203 223 if (preg_match('/^_(pre|post)_validator$/', $name, $match)) … … 249 269 public function enhanceWidget(sfWidget $widget, $object = null) 250 270 { 271 // form formatters 272 if ($widget instanceof sfWidgetFormSchema) 273 { 274 $name = $widget->getFormFormatterName(); 275 if (isset($this->config['formatters'][$name])) 276 { 277 $formatter = $this->config['formatters'][$name]; 278 $widget->addFormFormatter($name, new $formatter($widget)); 279 } 280 } 281 251 282 foreach (self::getLineage($widget) as $class) 252 283 {