buttflattery / yii2-formwizard

A Yii2 plugin used for creating stepped form or form wizard using yii\widgets\ActiveForm and \yii\db\ActiveRecord
https://yii2plugins.omaraslam.com/formwizard
Other
96 stars 13 forks source link

Using Kartik-V ActiveField #73

Closed zmoddynamics closed 4 years ago

zmoddynamics commented 4 years ago

Hello,

By chance would you be able to provide an example of how to use this form wizard with an ActiveField Widget:

https://demosbs3.krajee.com/widget-details/active-field

I have tried specifying the 'widget' settings but cannot seem to get it to work.

buttflattery commented 4 years ago

I didnt get time to try it but it should work , you havent added any code you are using here , please add your code. @zmoddynamics

buttflattery commented 4 years ago

@zmoddynamics I dont think you can use those options here in the widget if you go through the note there

Pre-Requisites The kartik\widgets\ActiveForm widget requires the extended kartik\widgets\ActiveField component to provide all functionality. Ensure, this pre-requisite is complied with in your widget calls. Any customization should be done by extending these kartik\widgets\ActiveForm or kartik\widgets\ActiveField classes.

which means that you form needs to be kartik\widgets\ActiveForm and the yii2-formwizard extends bootstrap widget , what you can try on your end is to override the createForm function https://github.com/buttflattery/yii2-formwizard/blob/master/src/FormWizard.php#L645 and add an option to provide the class namespace in the formoptions from the widget interface . and give it a try, you will have to provide the active-field widget options under the inputOptions to make it work for example if you have a username field in the step you can configure that field like

                'username' => [
                    'inputOptions' => ['addon' => ['prepend' => ['content' => '@']]],
                ],