October: Widget not been found after using repeater - RainLab.Pages

Created on 19 Sep 2019  路  31Comments  路  Source: octobercms/october

  • OctoberCMS Build: ### 458
  • PHP Version: 7.1.3
  • Database Engine: phpMyAdmin
  • Plugins Installed: staticPages

Description:

After creating new static page and clicking to add new image using repeater, I get this error.
Screenshot_1
If the page is saved, right after is created, repeater works fine.
If I use this image upload without repeater works fine too. I'm not using any .yaml files or anything special.

Repeater code

{repeater name="slike" tab="Vsebina" prompt="Dodaj sliko"}
  {variable type="mediafinder" mode="image" name="image" label="Slika"}{/variable}
  {variable type="text" name="alt" label="alt"}{/variable}
{/repeater}

Steps To Reproduce:

  1. Install OctoberCMS
  2. Install staticPages plugin
  3. Add repeater code to your layout
Bug

Most helpful comment

@ivang76 yeah I've seen the same - will investigate further. I'd dare say it's the same issue, just happening at another point (ie. on the initial save)

All 31 comments

I'm having the same issue...

@mskraban @weinde what version of Static Pages are you using? This should be fixed in v1.2.21. Related: #4230, #4158, https://github.com/rainlab/pages-plugin/issues/254, https://github.com/rainlab/pages-plugin/commit/eee885c0c7c136665af40b6e68e3f59f749eea5f

@LukeTowers i'm using the latest version of static pages 1.3.0. It works only if you first save page when you create it, and then close page and reopen. Then repeater works. Is there any workaround for this bug?

@mskraban Would you mind testing the fix in https://github.com/rainlab/pages-plugin/pull/421 and let me know if that resolves the issue for you?

@bennothommo I just tested, but error is still here. I'm using Rainlab static pages plugin 1.3.1

@mskraban Just to check, did you test by simply updating the plugin, or by implementing the changes made in that PR I linked?

@BenjaVR At first, I tested it by just updating the plugin, now I tested with implementing the changes made in the linked PR, but now I get new error.

Screenshot_1

@mskraban Whoops, can you try adding an extra ) at the end of that line before the semi-colon. I will roll out a fix for that now.

@bennothommo Yep, I added extra bracket at the end, but still same problem.
Screenshot_2

Hi there,
I'm still having the same issue.
Using a custom template with two tabs and many repeaters, if I don't save the new page before add one item I get this error:

A widget with class name 'formPage3ec59d3bd70c04f2a60e79e78626f893ViewBagElements' has not been bound to the controller" on line 605 of C:\laragon2\www\TTTTT\modules\backend\classes\Controller.php

Plugin version : 1.3.5
October build : 469

@ivang76 please post your field config .yaml file where this error is occuring and we'll try and replicate.

Hi @bennothommo
the field conf isn't in the yaml but I used the "variable" definition directly into the template page.
Something like this:

{variable name="main_title" label="Titolo pagina" placeholder="Titolo della pagina" tab="Titolo pagina" type="text"}{/variable}
{variable name="google_noindex" label="Non indicizzare la pagina in Google" tab="No index" type="checkbox" placement="primary"}{/variable}
{variable name="generic_noindex" label="Non indicizzare la pagina in altri motori di ricerca" tab="No index" type="checkbox" placement="primary"}{/variable}

{repeater name="images" prompt="Aggiungi immagini o url video" tab="Slider"}
{variable name="banner" label="Banner" type="mediafinder" mode="image"}{/variable}
{variable name="video" label="Video" placeholder="Youtube or Vimeo link" type="text"}{/variable}
{/repeater}

{repeater name="elements" prompt="Aggiungi un blocco testo" tab="Blocchi testo"}
{variable type="text" name="title" label="Titolo"}{/variable}
{# variable type="textarea" name="panel_content" label="Content"}Content{/variable} #}
{variable type="richeditor" name="body" label="Descrizione"}{/variable}
{variable type="mediafinder" name="photo" mode="image" label="Foto" imageWidth="200" imageHeight="200"}{/variable}
{variable type="radio" name="type" label="Tipo di blocco" options="0:Blocco testo con filetto|1:Blocco testo con cornice|2:Accordion|3:Blocco testo con immagine"}{/variable}
{/repeater}

{variable type="radio" name="dx_column" label="Colonna di destra" options="1:On|0:Off" tab="Colonna a destra"}{/variable}

{repeater name="quicklinks" prompt="Aggiungi un quicklink" tab="Colonna a destra"}
{variable type="text" name="title" label="Title"}{/variable}
{variable type="text" name="url" label="Url"}{/variable}
{variable type="checkbox" name="target" label="Apri in una nuova scheda"}{/variable}
{/repeater}

{repeater name="attachments" prompt="Aggiungi un allegato" tab="Colonna a destra"}
{variable type="text" name="name" label="Nome dell鈥檈tichetta"}{/variable}
{variable type="mediafinder" name="mediafinder" mode="file" label="Allega o seleziona un file"}{/variable}
{/repeater}

Let me know please if you can replicate and fix it. Thank you!

did you find time to investigate?
thank you!

@ivang76 sorry, I have been away for the past couple of days and have not yet had a chance to have a look. I will give it a look in the next day or so.

Hi @bennothommo, in the meantime that you will find time to check it out, may I ask you another thing related to these "Custom page fields" please?
How and where can I manage the validations of that _{repeaters}_ and _{variables}_ before to save them and, if it fails, to alert the user?
On a my custom model I normally use the beforeSave function, maybe can I do something similar?

Thanks for all as usual!

@ivang76 I believe it's possible through the plugin architecture.

You could potentially create your own plugin and then implement a listener for the model.beforeValidate event to programatically insert the validation rules. @seanthepottingshed has an example in this old issue which you could give a try: https://github.com/octobercms/october/issues/4327#issuecomment-491704920

You may have to try the following adjustment as well: https://github.com/octobercms/october/issues/4327#issuecomment-495677694.

@ivang76 I've finally gotten around to testing your template code (with the latest develop version of October CMS) and I cannot replicate the error you encountered. It potentially may have been fixed in the Laravel 6 update for October.

If possible, please try and update October CMS to version 1.1.0 and re-test.

Hi @bennothommo,
thanks for the advices about the validation of custom fields, I'm gonna make some test.

Instead unfortunately even with the Laravel 6 update I still get that _"A widget with class name 'formPage04cc1efcf2a6200b8326a39b207098e0ViewBagElements' has not been bound to the controller" on line 605 of [...]"_ error when I click to add a new repeater item on a new (not yet saved) page.

@bennothommo I encountered that too on the latest develop branch but haven't dug into what's causing it.

@LukeTowers the only way I've been able to replicate this is when I made another layout available to the Static Pages plugin. Interestingly, the default layout worked before this new layout was made available, but started showing the same issue after the layout was made available.

@ivang76 Are you using multiple layouts?

@bennothommo that sounds about right, I usually have a number of different layouts that I make available to the RainLab.Pages plugin

@bennothommo yes sure, there are different layouts from basic to complex (using custom fields with _variables_ and _repeaters_) that the editor can select.
Sorry if I didn't mention this case before.

@ivang76 @LukeTowers would you mind trying the fix in https://github.com/rainlab/pages-plugin/commit/d2ff05e8b8a6815a34c71f91b06eacc91fbe79f5 and see if that resolves the issue for you both?

thank you @bennothommo, this fix seems to work, but now I noticed a new strange behaviour: there isn't anymore the popup alert with the error, but the repeater fields are not saved.

Let me explain... if I create a new page and fill the repeater (no more blocking error) and save the page, and after that I reload it, the repeater fields won't be there anymore. The repeater block in the form is empty.
To store the page and keep the data I have to save twice.

@ivang76 yeah I've seen the same - will investigate further. I'd dare say it's the same issue, just happening at another point (ie. on the initial save)

hi there @bennothommo, did you find time to investigate again a bit about the issue?
thank you

excuse me guys, are there maybe some updates on this issue?
thanks

@ivang76 we've had to re-prioritise other work. If you would like this to be expedited, please consider putting a bounty on it.

Hi @bennothommo, in the meantime the issue isn't fixed I would like to add simply a check to prevent the problem and advice the user with a message like "please save the page before to add elements".

Could you give me some tips how and where insert this workaround maybe? I guess should be in the plugin.php under a \Event::listen...

thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d3monfiend picture d3monfiend  路  3Comments

EbashuOnHolidays picture EbashuOnHolidays  路  3Comments

mittultechnobrave picture mittultechnobrave  路  3Comments

Flynsarmy picture Flynsarmy  路  3Comments

sozonovalexey picture sozonovalexey  路  3Comments