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

No fields shown #72

Closed patschwork closed 4 years ago

patschwork commented 4 years ago

Hi there, I just tested the yii2-formwizard with a very small try (view source below). In no case any Fields were visible. With the browser debugging tools I could see, that the fields were rendered. I also tried to manipulate the css and classes with no success.

Nothing of the above helped.

Any hints of what I'm doing wrong?

View


<?php
use buttflattery\formwizard\FormWizard;

// $formModel = new \app\models\FormBulkLoaderWizard();
$formModel = new \app\models\Glossary();

echo FormWizard::widget([
    'formOptions' => [
        'id' => 'my_form_tabular'
    ],
    "steps"=>
    [
        [
          'title'=>'Step Title',
          'model'=> [$formModel],

            //set step type to tabular
            'type' => FormWizard::STEP_TYPE_TABULAR,

            'fieldConfig' => [
                'shoot_id' => [
                    'containerOptions' => [
                        'class' => 'form-group'
                    ],
                    'options' => [
                        'type' => 'dropdown',
                        'itemsList' => [1=>"test", 2=>"test2"],
                        'prompt' => 'Please select a value'
                    ]
                ],
            ],
        ]
    ]
]);

?>
`
buttflattery commented 4 years ago

hello @patschwork it does work for me, I just copy pasted and it shows up. I just replaced your model with the User model

image

are you sure you are using yii\db\ActiveRecord model and not the yii\base\Model ?

buttflattery commented 4 years ago

You dont need to create a form model when using this widget, it actually does the same work a form model can , it colletively shows the inputs from all the models configured in the steps and they need to be an yii\db\ActiveRecord model and not a yii\base\Model that is the first line written in the description of the widget on the home page.

patschwork commented 4 years ago

Hi @buttflattery,

thank you very much for the reply.

Mhmhm, that's strange: Now I tried the User-Model. Then I get

"Argument 1 passed to buttflattery\formwizard\step\Sorter::getStepFields() must be an instance of yii\base\Model, instance of app\models\User given, called in /var/www/dev/dwh_meta/frontend/yii/basic/vendor/buttflattery/yii2-formwizard/src/step/Sorter.php on line 42". That may be because, in my version of Yii2 the User-Model is extended of class User extends \yii\base\Object implements \yii\web\IdentityInterface. (I don't think I changed the code of the User-Model of the framework because I use an extension).

Nevertheless: I first tried (in the very first code snippet) with yii\base\Model (because I want to create an individual wizard). But then I had no luck and tried with a yii\db\ActiveRecord (thats the \app\models\Glossary() which extends from yii\db\ActiveRecord / you can see the source over here)

patschwork commented 4 years ago

Hi @buttflattery,

I tried again with the first example on a vm (it's the test machine with a deployed version of the application) and it worked at once... I compared the PHP versions. It's all the same... It seems to be a local issue... (actually I don't get it, what's the difference. I have to go deeper - maybe a php module)

Thank you very much for your help!

buttflattery commented 4 years ago

@patschwork that is odd can you share the composer show -i details . also sory for incorrect info i gave you in my previous comment, please ignore it

You dont need to create a form model when using this widget, it actually does the same work a form model can , it colletively shows the inputs from all the models configured in the steps and they need to be an yii\db\ActiveRecord model and not a yii\base\Model that is the first line written in the description of the widget on the home page.

this is not true You can use any of them i just havent been working on this extension in the last few months , and was busy on other projects and totally forgot that i have updated to support any model you are using , you can even integrate the efault ContactForm that comes in with the default Yii2 installation which is a Form model extending yii\base\Model. I just realized all this after i saw the error you mentioned

Argument 1 passed to buttflattery\formwizard\step\Sorter::getStepFields() must be an instance of yii\base\Model, instance of app\models\User given, called in /var/www/dev/dwh_meta/frontend/yii/basic/vendor/buttflattery/yii2-formwizard/src/step/Sorter.php on line 42".

patschwork commented 4 years ago

Hi @buttflattery

Here's the output of composer show -i

2amigos/2fa-library                   1.0.3              2 Factor Authentication (2FA) library
2amigos/qrcode-library                1.1.2              QrCode Generator
2amigos/yii2-selectize-widget         1.1.0              The selectize.js widget for the Yii framework
2amigos/yii2-usuario                  1.1.2              Highly customizable and extensible user management, authentication, and authorization Yii2 extension
bacon/bacon-qr-code                   1.0.3              BaconQrCode is a QR code generator for PHP.
bluezed/yii2-float-thead              v1.0.9             This is a Yii 2 wrapper for jquery.floatThead a floating/locked/sticky/fixed table header plugin that requires no special CSS and supports window and overflow scrolling.
bower-asset/bootstrap                 v3.3.7             The most popular front-end framework for developing responsive, mobile first projects on the web.
bower-asset/codemirror                5.25.2            
bower-asset/floatthead                2.1.4             
bower-asset/jquery                    2.2.4             
bower-asset/jquery-ui                 1.11.4            
bower-asset/jquery.inputmask          3.3.6              Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.
bower-asset/microplugin               v0.0.3            
bower-asset/punycode                  v1.3.2            
bower-asset/selectize                 v0.12.4           
bower-asset/sifter                    v0.5.3            
bower-asset/typeahead.js              v0.11.1           
bower-asset/yii2-pjax                 v2.0.6            
buttflattery/yii2-formwizard          1.7.9              A yii2 widget for form wizard, to create a multistep form.
cebe/markdown                         1.1.2              A super fast, highly extensible markdown parser for PHP
cmrcx/phptidy                         v3.0               PHP code formatter
composer/semver                       1.4.2              Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler               1.4.1              Restarts a process without Xdebug.
conquer/codemirror                    2.0                Yii2 codemirror widget
conquer/helpers                       2.0.10             Yii2 helpers
dmstr/yii2-bootstrap                  0.2.0              yii2 bootstrap components and extensions from diemeisterei GmbH
dmstr/yii2-db                         0.9.3              Database extensions
dmstr/yii2-helpers                    0.4.5              Yii2 Helpers
dnoegel/php-xdg-base-dir              0.1                implementation of xdg base directory specification for php
doctrine/annotations                  v1.4.0             Docblock Annotations Parser
doctrine/lexer                        v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
ezyang/htmlpurifier                   v4.9.3             Standards compliant HTML filter written in PHP
friendsofphp/php-cs-fixer             v2.16.0            A tool to automatically fix PHP code style
fzaninotto/faker                      v1.7.1             Faker is a PHP library that generates fake data for you.
gecko-packages/gecko-php-unit         v2.2               Additional PHPUnit asserts and constraints.
jakub-onderka/php-console-color       0.1               
jakub-onderka/php-console-highlighter v0.3.2            
kartik-v/dependent-dropdown           v1.4.8             A multi level dependent dropdown JQuery plugin that allows nested dependencies.
kartik-v/yii2-krajee-base             dev-master 2f38bde Base library and foundation components for all Yii2 Krajee extensions.
kartik-v/yii2-widget-depdrop          dev-master 6918ca6 Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets)
kartik-v/yii2-widget-select2          dev-master 3276154 Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
khanamiryan/qrcode-detector-decoder   1                  QR code decoder / reader
lajax/yii2-translate-manager          1.7.1              Online Translate
mikehaertl/php-shellcommand           1.3.0              An object oriented interface to shell commands
nikic/php-parser                      v3.1.5             A PHP parser written in PHP
paragonie/constant_time_encoding      v1.0.1             Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)
paragonie/random_compat               v2.0.11            PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
php-cs-fixer/diff                     v1.3.0             sebastian/diff v2 backport support for PHP5.6
phpspec/php-diff                      v1.1.0             A comprehensive library for generating differences between two hashable objects (strings or arrays).
psr/log                               1.0.2              Common interface for logging libraries
psy/psysh                             v0.8.18            An interactive shell for modern PHP.
raven/raven                           0.15.0             A PHP client for Sentry (http://getsentry.com)
schmunk42/retry                       0.0.1              A tiny library for retrying failing operations.
schmunk42/yii2-giiant                 0.9.2              Gii CRUD generator for Yii 2 Framework
sheershoff/yii2-sentry-component      dev-master 74ffe94 A Yii2 component for Sentry allowing data arrays passing through Yii2 logging methods
sitawit/yii2-piwik                    dev-master c676329 The Piwiki plugin for Yii 2 framework
swiftmailer/swiftmailer               v5.4.8             Swiftmailer, free feature-rich PHP mailer
symfony/console                       v3.4.17            Symfony Console Component
symfony/css-selector                  v2.8.0             Symfony CssSelector Component
symfony/debug                         v3.4.0             Symfony Debug Component
symfony/dom-crawler                   v2.8.0             Symfony DomCrawler Component
symfony/event-dispatcher              v3.4.0             Symfony EventDispatcher Component
symfony/filesystem                    v3.4.0             Symfony Filesystem Component
symfony/finder                        v3.4.0             Symfony Finder Component
symfony/options-resolver              v3.4.0             Symfony OptionsResolver Component
symfony/polyfill-mbstring             v1.6.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php70                v1.6.0             Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72                v1.6.0             Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process                       v3.4.0             Symfony Process Component
symfony/stopwatch                     v3.4.0             Symfony Stopwatch Component
symfony/var-dumper                    v3.4.9             Symfony mechanism for exploring and dumping PHP variables
wbraganca/yii2-dynamicform            v2.0.1             It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.
yiidoc/yii2-redactor                  2.0.1              Extension redactor for Yii2 Framework.
yiisoft/yii2                          2.0.12             Yii PHP Framework Version 2
yiisoft/yii2-authclient               2.1.3              External authentication via OAuth and OpenID for the Yii framework
yiisoft/yii2-bootstrap                2.0.7              The Twitter Bootstrap extension for the Yii framework
yiisoft/yii2-codeception              2.0.6              The Codeception integration for the Yii framework
yiisoft/yii2-composer                 2.0.5              The composer plugin for Yii extension installer
yiisoft/yii2-debug                    2.0.12             The debugger extension for the Yii framework
yiisoft/yii2-faker                    2.0.3              Fixture generator. The Faker integration for the Yii framework.
yiisoft/yii2-gii                      2.0.5              The Gii extension for the Yii framework
yiisoft/yii2-httpclient               2.0.4              HTTP client extension for the Yii framework
yiisoft/yii2-jui                      2.0.6              The Jquery UI extension for the Yii framework
yiisoft/yii2-shell                    2.0.1              The interactive shell extension for Yii framework
yiisoft/yii2-swiftmailer              2.0.7              The SwiftMailer integration for the Yii framework
buttflattery commented 4 years ago

@patschwork you have Yii2 V2.0.12 that is way too old, can you confirm if that is the version on local you have ? where you are facing the problem

patschwork commented 4 years ago

@buttflattery Yii2 V2.0.12 is correct. But I also tried with Yii2 V2.0.35, that's not the root cause.

I think I got it: It's the bluezed/yii2-float-thead component. (That's the difference). I tested a feat branch where this component is not installed on the same workstation and then the fields shows as expected...

patschwork commented 4 years ago

You dont need to create a form model when using this widget, it actually does the same work a form model can , it colletively shows the inputs from all the models configured in the steps and they need to be an yii\db\ActiveRecord model and not a yii\base\Model that is the first line written in the description of the widget on the home page.

this is not true You can use any of them i just havent been working on this extension in the last few months , and was busy on other projects and totally forgot that i have updated to support any model you are using , you can even integrate the efault ContactForm that comes in with the default Yii2 installation which is a Form model extending yii\base\Model. I just realized all this after i saw the error you mentioned

By the way: Thanks for the info :-)