Future addButton() syntax – I need your suggestions
I’d like to hear your opinion about some suggestions towards button implementation
Currently there are 2 versions running around:
1) $form->addButton()->redirect(‘/’) - in this one form’s addButton is returning $js(‘click’)->univ() of the button. This is backward compatible version and seriously, why would we need to do anything with button but redirect.
2) $form->addButton()->js(‘click’)->univ()->redirect(‘/’) – here addButton returns “View_Button” object. The benefit is that you can do certain things with is such as addLabel or setStyle(), which will affect how button looks. Also instead of just clicks you can use other events, such as mouse-over etc. This is more standard-compliant version IMHO
I’d like to hear from you, which implementation of Form::addButton and Grid::addButton you prefer? Also to help with compatibility Button::redirect() implemented through #2 will allow for syntax of #1 but this is for obsolete syntax and should be avoided.