Re: [symfony-users] Form decorator
Thanks for the awesome write-up! :) Really helpful, cheers, Daniel On 19.04.2010, at 07:24, Gareth McCumskey wrote: So As I said before, I was going to do a blog post on this to sum up the entire thing. I have now finally done it if anyone is interested: http://www.synaq.com/news-releases/advanced-form-techniques-for-symfony Thanks again to Sid for the help On Tue, Feb 23, 2010 at 10:32 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: and I know the names can cause some giggles but hey :P LOL ... so ... any interesting website project lately? :P Happy coding and bye for now. On Tue, Feb 23, 2010 at 9:20 PM, Gareth McCumskey gmccums...@gmail.com wrote: Well just to conclude this, I saw an example on one of the symfony docs about overwriting the formatRow method. Firstly, my big thanks to you Sid as I would not have gotten this far without your help the community again has come to the rescue. Now for anyone that may find this useful in future here is how it looks in the end: My form consists of some dynamic form fields created based on values sent in an array when the form is constructed: public function __construct($extra_inputs = array()) { $this-extra_inputs = $extra_inputs; parent::__construct(); } In addition I had to create my own custom widget which is essentially just an ajax link to an action that forwards the value of one input box to the action, adds that value to a session array, sends the session array to the form using the $extra_inputs parameter above and redisplays the form in the div with the new input box for that value added. So, my difficulty was that each new extra_input needed to use that ajax link widget again alongside it but would forward to a Remove action to remove that input from the session variable and hence from the form. What I needed was that each new dynamic extra_input and its associated Remove ajax link widget to be displayed one per line. My decorator class hence looks like such and I know the names can cause some giggles but hey :P : class mailAnalByRecip extends sfWidgetFormSchemaFormatter { protected $rowFormat = \n%error%\nspan class=\formRow\\nspan class=\formLabel\%label%/span\nspan class=\formField\%field%\n%help%/span/span\n%hidden_fields%, $helpFormat = 'span class=fieldHelp%help%/span', $errorRowFormat = span\n%errors%br //span\n, $errorListFormatInARow = ul%errors%/ul\n, $errorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $namedErrorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $decoratorFormat = %content%; protected $fields_to_format = array(); public function __construct(sfWidgetFormSchema $widgetSchema, $fields_to_format) { $this-fields_to_format = $fields_to_format; parent::__construct($widgetSchema); } public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { foreach ($this-fields_to_format as $field_name) { if (strpos($field, $field_name) !== false strpos($field, 'type=text') !== false) { $field = 'span class=field_row'.$field; } else if (strpos($field, $field_name) !== false strpos($field, 'a') !== false) { $field = $field.'/span'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); return $row; } } And in my form class at the very end of the configure() method: $decorator = new mailAnalByRecip($this-widgetSchema, $this-extra_inputs); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); So there we go. A form class that dynamically creates widgets based on values in an array, as well as dynamically creating a custom ajax link widget and keeping the input and its ajax link widget associated visually using a custom form decorator class to add spans before and after the two widgets. WHEW! That was one HELLUVA learning experience LOL On Tue, Feb 23, 2010 at 10:09 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg
Re: [symfony-users] Form decorator
So As I said before, I was going to do a blog post on this to sum up the entire thing. I have now finally done it if anyone is interested: http://www.synaq.com/news-releases/advanced-form-techniques-for-symfony Thanks again to Sid for the help On Tue, Feb 23, 2010 at 10:32 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: and I know the names can cause some giggles but hey :P LOL ... so ... any interesting website project lately? :P Happy coding and bye for now. On Tue, Feb 23, 2010 at 9:20 PM, Gareth McCumskey gmccums...@gmail.com wrote: Well just to conclude this, I saw an example on one of the symfony docs about overwriting the formatRow method. Firstly, my big thanks to you Sid as I would not have gotten this far without your help the community again has come to the rescue. Now for anyone that may find this useful in future here is how it looks in the end: My form consists of some dynamic form fields created based on values sent in an array when the form is constructed: public function __construct($extra_inputs = array()) { $this-extra_inputs = $extra_inputs; parent::__construct(); } In addition I had to create my own custom widget which is essentially just an ajax link to an action that forwards the value of one input box to the action, adds that value to a session array, sends the session array to the form using the $extra_inputs parameter above and redisplays the form in the div with the new input box for that value added. So, my difficulty was that each new extra_input needed to use that ajax link widget again alongside it but would forward to a Remove action to remove that input from the session variable and hence from the form. What I needed was that each new dynamic extra_input and its associated Remove ajax link widget to be displayed one per line. My decorator class hence looks like such and I know the names can cause some giggles but hey :P : class mailAnalByRecip extends sfWidgetFormSchemaFormatter { protected $rowFormat = \n%error%\nspan class=\formRow\\nspan class=\formLabel\%label%/span\nspan class=\formField\%field%\n%help%/span/span\n%hidden_fields%, $helpFormat = 'span class=fieldHelp%help%/span', $errorRowFormat = span\n%errors%br //span\n, $errorListFormatInARow = ul%errors%/ul\n, $errorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $namedErrorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $decoratorFormat = %content%; protected $fields_to_format = array(); public function __construct(sfWidgetFormSchema $widgetSchema, $fields_to_format) { $this-fields_to_format = $fields_to_format; parent::__construct($widgetSchema); } public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { foreach ($this-fields_to_format as $field_name) { if (strpos($field, $field_name) !== false strpos($field, 'type=text') !== false) { $field = 'span class=field_row'.$field; } else if (strpos($field, $field_name) !== false strpos($field, 'a') !== false) { $field = $field.'/span'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); return $row; } } And in my form class at the very end of the configure() method: $decorator = new mailAnalByRecip($this-widgetSchema, $this-extra_inputs); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); So there we go. A form class that dynamically creates widgets based on values in an array, as well as dynamically creating a custom ajax link widget and keeping the input and its ajax link widget associated visually using a custom form decorator class to add spans before and after the two widgets. WHEW! That was one HELLUVA learning experience LOL On Tue, Feb 23, 2010 at 10:09 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input
Re: [symfony-users] Form decorator
You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input maxlength=50 type=text name=test[first_name] id=test_first_name / into spaninput maxlength=50 type=text name=test[first_name] id=test_first_name /*/ //Now what? } On Tue, Feb 23, 2010 at 9:43 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Actually I got very curious and did an experiment myself.Parameter $field turns out to be a string like: 'input maxlength=50 type=text name=test[first_name] id=test_first_name /' So I guess the solution would be a little bit hacky, involving some regex to detect which field it is and give it a different format (e.g.: add span prefix on one field and append /span on the second field) :-\ On Tue, Feb 23, 2010 at 8:23 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: If you look in sfWidgetFormSchemaFormatter class, you could probably override method: public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) detect the special field through the $field parameter and give it a different formatting. On Tue, Feb 23, 2010 at 8:21 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Oh I just understood why you can't do it LOL sorry On Tue, Feb 23, 2010 at 8:20 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to
Re: [symfony-users] Form decorator
Well just to conclude this, I saw an example on one of the symfony docs about overwriting the formatRow method. Firstly, my big thanks to you Sid as I would not have gotten this far without your help the community again has come to the rescue. Now for anyone that may find this useful in future here is how it looks in the end: My form consists of some dynamic form fields created based on values sent in an array when the form is constructed: public function __construct($extra_inputs = array()) { $this-extra_inputs = $extra_inputs; parent::__construct(); } In addition I had to create my own custom widget which is essentially just an ajax link to an action that forwards the value of one input box to the action, adds that value to a session array, sends the session array to the form using the $extra_inputs parameter above and redisplays the form in the div with the new input box for that value added. So, my difficulty was that each new extra_input needed to use that ajax link widget again alongside it but would forward to a Remove action to remove that input from the session variable and hence from the form. What I needed was that each new dynamic extra_input and its associated Remove ajax link widget to be displayed one per line. My decorator class hence looks like such and I know the names can cause some giggles but hey :P : class mailAnalByRecip extends sfWidgetFormSchemaFormatter { protected $rowFormat = \n%error%\nspan class=\formRow\\nspan class=\formLabel\%label%/span\nspan class=\formField\%field%\n%help%/span/span\n%hidden_fields%, $helpFormat = 'span class=fieldHelp%help%/span', $errorRowFormat = span\n%errors%br //span\n, $errorListFormatInARow = ul%errors%/ul\n, $errorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $namedErrorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $decoratorFormat = %content%; protected $fields_to_format = array(); public function __construct(sfWidgetFormSchema $widgetSchema, $fields_to_format) { $this-fields_to_format = $fields_to_format; parent::__construct($widgetSchema); } public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { foreach ($this-fields_to_format as $field_name) { if (strpos($field, $field_name) !== false strpos($field, 'type=text') !== false) { $field = 'span class=field_row'.$field; } else if (strpos($field, $field_name) !== false strpos($field, 'a') !== false) { $field = $field.'/span'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); return $row; } } And in my form class at the very end of the configure() method: $decorator = new mailAnalByRecip($this-widgetSchema, $this-extra_inputs); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); So there we go. A form class that dynamically creates widgets based on values in an array, as well as dynamically creating a custom ajax link widget and keeping the input and its ajax link widget associated visually using a custom form decorator class to add spans before and after the two widgets. WHEW! That was one HELLUVA learning experience LOL On Tue, Feb 23, 2010 at 10:09 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input maxlength=50 type=text name=test[first_name] id=test_first_name / into spaninput maxlength=50 type=text name=test[first_name] id=test_first_name /*/ //Now what? } On Tue, Feb 23, 2010 at 9:43 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Actually I got very curious and did an experiment myself.Parameter $field turns out to be a string like: 'input maxlength=50 type=text name=test[first_name] id=test_first_name /' So I guess the solution would be a little bit hacky, involving some regex to detect which field it is and give it a
Re: [symfony-users] Form decorator
I think this entire process will make an interesting blog post which I'll do later today On Tue, Feb 23, 2010 at 10:20 AM, Gareth McCumskey gmccums...@gmail.com wrote: Well just to conclude this, I saw an example on one of the symfony docs about overwriting the formatRow method. Firstly, my big thanks to you Sid as I would not have gotten this far without your help the community again has come to the rescue. Now for anyone that may find this useful in future here is how it looks in the end: My form consists of some dynamic form fields created based on values sent in an array when the form is constructed: public function __construct($extra_inputs = array()) { $this-extra_inputs = $extra_inputs; parent::__construct(); } In addition I had to create my own custom widget which is essentially just an ajax link to an action that forwards the value of one input box to the action, adds that value to a session array, sends the session array to the form using the $extra_inputs parameter above and redisplays the form in the div with the new input box for that value added. So, my difficulty was that each new extra_input needed to use that ajax link widget again alongside it but would forward to a Remove action to remove that input from the session variable and hence from the form. What I needed was that each new dynamic extra_input and its associated Remove ajax link widget to be displayed one per line. My decorator class hence looks like such and I know the names can cause some giggles but hey :P : class mailAnalByRecip extends sfWidgetFormSchemaFormatter { protected $rowFormat = \n%error%\nspan class=\formRow\\nspan class=\formLabel\%label%/span\nspan class=\formField\%field%\n%help%/span/span\n%hidden_fields%, $helpFormat = 'span class=fieldHelp%help%/span', $errorRowFormat = span\n%errors%br //span\n, $errorListFormatInARow = ul%errors%/ul\n, $errorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $namedErrorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $decoratorFormat = %content%; protected $fields_to_format = array(); public function __construct(sfWidgetFormSchema $widgetSchema, $fields_to_format) { $this-fields_to_format = $fields_to_format; parent::__construct($widgetSchema); } public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { foreach ($this-fields_to_format as $field_name) { if (strpos($field, $field_name) !== false strpos($field, 'type=text') !== false) { $field = 'span class=field_row'.$field; } else if (strpos($field, $field_name) !== false strpos($field, 'a') !== false) { $field = $field.'/span'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); return $row; } } And in my form class at the very end of the configure() method: $decorator = new mailAnalByRecip($this-widgetSchema, $this-extra_inputs); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); So there we go. A form class that dynamically creates widgets based on values in an array, as well as dynamically creating a custom ajax link widget and keeping the input and its ajax link widget associated visually using a custom form decorator class to add spans before and after the two widgets. WHEW! That was one HELLUVA learning experience LOL On Tue, Feb 23, 2010 at 10:09 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input maxlength=50 type=text name=test[first_name] id=test_first_name / into spaninput maxlength=50 type=text name=test[first_name] id=test_first_name /*/ //Now what? } On Tue, Feb 23, 2010 at 9:43 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Actually I got very curious and did an experiment myself.Parameter $field turns out to be a string like: 'input maxlength=50 type=text
Re: [symfony-users] Form decorator
and I know the names can cause some giggles but hey :P LOL ... so ... any interesting website project lately? :P Happy coding and bye for now. On Tue, Feb 23, 2010 at 9:20 PM, Gareth McCumskey gmccums...@gmail.com wrote: Well just to conclude this, I saw an example on one of the symfony docs about overwriting the formatRow method. Firstly, my big thanks to you Sid as I would not have gotten this far without your help the community again has come to the rescue. Now for anyone that may find this useful in future here is how it looks in the end: My form consists of some dynamic form fields created based on values sent in an array when the form is constructed: public function __construct($extra_inputs = array()) { $this-extra_inputs = $extra_inputs; parent::__construct(); } In addition I had to create my own custom widget which is essentially just an ajax link to an action that forwards the value of one input box to the action, adds that value to a session array, sends the session array to the form using the $extra_inputs parameter above and redisplays the form in the div with the new input box for that value added. So, my difficulty was that each new extra_input needed to use that ajax link widget again alongside it but would forward to a Remove action to remove that input from the session variable and hence from the form. What I needed was that each new dynamic extra_input and its associated Remove ajax link widget to be displayed one per line. My decorator class hence looks like such and I know the names can cause some giggles but hey :P : class mailAnalByRecip extends sfWidgetFormSchemaFormatter { protected $rowFormat = \n%error%\nspan class=\formRow\\nspan class=\formLabel\%label%/span\nspan class=\formField\%field%\n%help%/span/span\n%hidden_fields%, $helpFormat = 'span class=fieldHelp%help%/span', $errorRowFormat = span\n%errors%br //span\n, $errorListFormatInARow = ul%errors%/ul\n, $errorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $namedErrorRowFormatInARow = li class=\error\darr; %error% darr;/li\n, $decoratorFormat = %content%; protected $fields_to_format = array(); public function __construct(sfWidgetFormSchema $widgetSchema, $fields_to_format) { $this-fields_to_format = $fields_to_format; parent::__construct($widgetSchema); } public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { foreach ($this-fields_to_format as $field_name) { if (strpos($field, $field_name) !== false strpos($field, 'type=text') !== false) { $field = 'span class=field_row'.$field; } else if (strpos($field, $field_name) !== false strpos($field, 'a') !== false) { $field = $field.'/span'; } } $row = parent::formatRow($label, $field, $errors, $help, $hiddenFields); return $row; } } And in my form class at the very end of the configure() method: $decorator = new mailAnalByRecip($this-widgetSchema, $this-extra_inputs); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); So there we go. A form class that dynamically creates widgets based on values in an array, as well as dynamically creating a custom ajax link widget and keeping the input and its ajax link widget associated visually using a custom form decorator class to add spans before and after the two widgets. WHEW! That was one HELLUVA learning experience LOL On Tue, Feb 23, 2010 at 10:09 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: You attach your decorator class to your form, e.g.: class yourForm extends sfForm { function configure() { /* configure your fields */ $decorator = new yourFormFormatter($this-widgetSchema); $this-widgetSchema-addFormFormatter('custom', $decorator); $this-widgetSchema-setFormFormatterName('custom'); } } On Tue, Feb 23, 2010 at 8:55 PM, Gareth McCumskey gmccums...@gmail.com wrote: Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input maxlength=50 type=text name=test[first_name] id=test_first_name / into spaninput maxlength=50 type=text name=test[first_name] id=test_first_name /*/ //Now what? } On Tue, Feb 23, 2010 at 9:43 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Actually I got very curious and did an experiment myself.Parameter $field turns out
[symfony-users] Form decorator
Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
Oh I just understood why you can't do it LOL sorry On Tue, Feb 23, 2010 at 8:20 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
If you look in sfWidgetFormSchemaFormatter class, you could probably override method: public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) detect the special field through the $field parameter and give it a different formatting. On Tue, Feb 23, 2010 at 8:21 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Oh I just understood why you can't do it LOL sorry On Tue, Feb 23, 2010 at 8:20 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
Actually I got very curious and did an experiment myself.Parameter $field turns out to be a string like: 'input maxlength=50 type=text name=test[first_name] id=test_first_name /' So I guess the solution would be a little bit hacky, involving some regex to detect which field it is and give it a different format (e.g.: add span prefix on one field and append /span on the second field) :-\ On Tue, Feb 23, 2010 at 8:23 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: If you look in sfWidgetFormSchemaFormatter class, you could probably override method: public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) detect the special field through the $field parameter and give it a different formatting. On Tue, Feb 23, 2010 at 8:21 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Oh I just understood why you can't do it LOL sorry On Tue, Feb 23, 2010 at 8:20 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
Re: [symfony-users] Form decorator
Just a question if I overwrite the formatRow method how do I return the newly formatted row to wherever eg public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) { /*Do stuff to make $field from input maxlength=50 type=text name=test[first_name] id=test_first_name / into spaninput maxlength=50 type=text name=test[first_name] id=test_first_name /*/ //Now what? } On Tue, Feb 23, 2010 at 9:43 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Actually I got very curious and did an experiment myself.Parameter $field turns out to be a string like: 'input maxlength=50 type=text name=test[first_name] id=test_first_name /' So I guess the solution would be a little bit hacky, involving some regex to detect which field it is and give it a different format (e.g.: add span prefix on one field and append /span on the second field) :-\ On Tue, Feb 23, 2010 at 8:23 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: If you look in sfWidgetFormSchemaFormatter class, you could probably override method: public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) detect the special field through the $field parameter and give it a different formatting. On Tue, Feb 23, 2010 at 8:21 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Oh I just understood why you can't do it LOL sorry On Tue, Feb 23, 2010 at 8:20 PM, Sid Bachtiar sid.bacht...@gmail.com wrote: Why can't you do something like this in template: ?php echo $form['not_special_1']-renderRow(); ? labelWe are special:/label span ?php echo $form['special_a']-render(); ? ?php echo $form['special_b']-render(); ? /span ?php echo $form['not_special_2']-renderRow(); ? On Tue, Feb 23, 2010 at 8:09 PM, Gareth McCumskey gmccums...@gmail.com wrote: All I really want to do is add a span around two widgets (spanwidget1 /widget2 //span). I cannot do this in the template because the template is designed to display many different form types so the form class needs to define the exact structure of the form. On Tue, Feb 23, 2010 at 9:07 AM, Sid Bachtiar sid.bacht...@gmail.com wrote: Don't know about the documentation. I had to look around myself to learn about it. Take a look at this example from my blog: http://bluehorn.co.nz/2009/08/31/symfony-12-sfform-formatter-to-add-stars-on-required-fields/ On Tue, Feb 23, 2010 at 7:57 PM, Gareth McCumskey gmccums...@gmail.com wrote: Hi guys, I have looked around for the documentation related to creating your own form decorators but the reference to it in the forms book for symfony 1.2 says look in Chapter 5 but there is no chapter 5 o.O Any pointers to where I could find the info would be appreciated. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- Blue Horn Ltd - System Development http://bluehorn.co.nz -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en. -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email