Create a function in your BaseForm class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public static function listenToPostConfigure($event) { $form = $event->getSubject(); $widgetSchema = $form->getWidgetSchema(); $validatorSchema = $form->getValidatorSchema(); $fields = $form->getFormFieldSchema()->getWidget()->getFields(); foreach ($fields as $key => $object) { $label = $form->getFormFieldSchema()->offsetGet($key)->renderLabelName(); if (isset($validatorSchema[$key]) and $validatorSchema[$key]->getOption('required') == true) { $title = $key . '_field_is_required'; $label .= '<sup>getFormFormatter()->translate($title) . '">*</sup>'; } $widgetSchema->setLabel($key, $label); } } |
Add a listener to the form.post_configure event with your function
1 2 | $dispatcher = $this->getEventDispatcher(); $dispatcher->connect('form.post_configure', array('BaseForm', 'listenToPostConfigure')); |
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.