Jump to content

Dependent field(s) shown with showIf condition in block don't persist.


iank
 Share

Recommended Posts

Hey @bernhard,

RPB is so great I decided to migrate from RepeaterMatrix for a site I'm working on 🙂

However, I came across a snag with a page reference field not saving to the DB.  I have a fairly basic 'RichText' block which in addition to the basic title/textarea fields has a checkbox to show a page reference page (single page) via a showIf condition.   If the checkbox is checked, the page reference field is shown:

image.thumb.png.461f04dde5a0f84abb5a39184070a59e.png

But when the block (or parent page) is saved, the chosen option doesn't get saved.   I know the page reference field works, because this is exactly the same logic (using the same fields) I've ported across from my RepeaterMatrix field. 

Furthermore, if I disable the "showIf" condition in the RPB block, the page reference once again works correctly.  

In the example above, I'm using a select dropdown, but I get the same behaviour if it's a Radio Buttons list. 

Any thoughts?

Much appreciated,

Ian.

 

  • Like 1
Link to comment
Share on other sites

Edit: 

OK, I think we can ignore the dependent field types involved (page reference, Fieldset (page)) - a simple example with just a checkbox and a textarea exhibits the same problem.  It definitely looks to be something related to the "showIf" condition rather than the underlying fields:

image.png.e029adb5cbc123062227769032935bd8.png

-----------------

Hi @bernhard, sorry to be a pain. In fact, I have the same problem if the dependent field is a FieldtypeFieldsetPage, as in this example: 

image.thumb.png.5990697bf270bd2f86cd7360368a4e99.png

This example is part of a Call to Action block.  The 'Action' field is a Select Options field, and the 'Link to Page' field is the Fieldset (Page) field containing the three nested fields you can see. 

None of those three fields are saved when the block or page is saved.  I think it must be something to do with the 'showIf' logic.

Again this logic is just moved over from a RepeaterMatrix field where it worked just fine.

Thx,

Ian.

  • Like 2
Link to comment
Share on other sites

  • iank changed the title to Dependent field(s) shown with showIf condition in block don't persist.

Hi @bernhard,

I discovered some more information which might help with troubleshooting.  I came across this post which seemed to be related:  https://processwire.com/talk/topic/29225-solved-show-this-field-only-if-doesnt-seem-to-work/.   As mentioned in that post, if I use Alfred on the front end, or choose "Edit in new window" from the admin side, the changed information does indeed get saved.

Only when editing the blocks in the admin in 'repeater mode' does the 'showIf' information not get saved. 

I hope that points you in the right direction (and for now I have a workaround!)

Thx,

Ian.

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 2/15/2024 at 4:57 PM, iank said:

RPB is so great I decided to migrate from RepeaterMatrix for a site I'm working on 🙂

Hey @iank sorry for ignoring this post for so long and thank you very much for the great feedback. Really glad you like it and hope you still do 🙂 

Thx to @FireWire the latest version of RPB v5.3.2 contains a fix for that issue 😎

For anybody interested: The reason for the issue is that whenever a RPB item is saved we need to also process all changed items. I was doing that by adding all block-fields to an InputfieldWrapper element and then calling ->processInput($wrapper). This worked well, but it does not support showIf, as FireWire explained to me. So he changed it to use InputfieldForm instead and now everything works as expected.

Let me know if everything works and please mark the topic as [solved], thx 🙂 

  • Like 1
Link to comment
Share on other sites

On 3/31/2024 at 9:28 AM, bernhard said:

Let me know if everything works

@bernhard, showIf conditions are now working as expected.  These are working in all three edit modes:  Full page edit, block "edit in new window" and front-end block edit with Alfred.

However, 

On 4/1/2024 at 4:36 PM, FireWire said:

Also confirmed that the fix makes it possible to use requireIf in blocks!

This is not working for me when editing a block in full page edit mode.  If a requiredIf condition is met, then none of the block's changes are persisted.  

When editing a block via "edit in new window" or front-end with Alfred, the requiredIf conditions work and the changes are saved. 

Sorry to be a pain - I think we're almost there, but I can't for the life of me figure out why this is happening only in the full page edit scenario.

I can create a screencast demonstrating the issue if that would be helpful.

Thx,
Ian.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@iank I'll double check on my end, I may have not tested thoroughly enough, or got inconsistent results.

Not sure about yours, but in my case the most important component was the showIf since it is the primary method of indicating the action a user should take and important way to keep the UI tidy. If you  continue configuring your fields to use requireIf then any update to RPB would mean those field settings will be respected. So hopefully it doesn't slow your development too much.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

12 minutes ago, FireWire said:

Not sure about yours, but in my case the most important component was the showIf since it is the primary method of indicating the action a user should take and important way to keep the UI tidy.

Likewise.  It's certainly not a deal-breaker, and the showIf fix is a big step forward for my needs. 👍

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...