Try our conversational search powered by Generative AI!

Field dependency does not work

Vote:
 

Hi,

So i have a selection dropdown and a textbox which should hide or show based on the selection dropdown value.

But on dropdown value change the textbox does not show/hide.

As read through old post, i have both below lines in my layout.cshtml


@Html.Raw(Html.RequiredClientResources(RenderingTags.Header)


@Html.Raw(Html.RequiredClientResources(RenderingTags.Footer)

Can anyone guide me how to fix this...

#228904
Oct 05, 2020 9:12
Vote:
 

Hi Swati,

Rendering of the Htm.RequiredClientResources is done in your "master" layout and that has nothing to do with hiding or showing something. Those are just to render to the header or footer required client resources (see documentation or look at the Episerver Alloy MVC demo site).

It is unclear to what "Old post" you are referring to. Is your intention to hide something in edit mode based on another propertys value? If yes, then see this blog post by Grzegorz which is about hiding or showing tabs and properties in edit mode.

If this is something else, then please explain what you are trying to achieve and what old blog post you are referring to.

#228918
Oct 05, 2020 15:31
Vote:
 

Hi Antti,

I saw below post with similar issue i suppose:

https://world.episerver.com/forum/developer-forum/episerver-forms/thread-container/2020/3/show-and-hide-dependencies-on-form-fields-not-working/

So im using Episerver form in which i have 2 form elements:

  1. Dropdown ( Selection control) -> For example - The data in this dropdown is Doctor, Nurse
  2. Textbox (Textbox control)

So im using the field dependency in the Textbox form element , that it should only be visible when the value of Dropdown is Nurse.

But i dont see the textbox control showing up when user selects the Nurse value.

#228920
Oct 05, 2020 16:00
Chen Nan - Jul 21, 2021 5:18
I encountered the same problem, how did you solve it?
Vote:
 

Hi Swati,

Tested with Alloy and using Episerver Forms version 4.29.3 and the text box only shown when selecting Nurse from dropdown.

So what version of Episerver Forms are you using?

Have you published your form elements? Do you have more than one Selection element in the form? If yes, check that you have dependecy set to the correct Selection element.

I used the following dependency settings in the textbox related to the 'Selection' element

  • this field will be 'shown'
  • if 'All'
  • 'Selection' equals 'Nurse' (selection uses the default value for Nurse and Doctor so the value for the item is also Doctor and Nurse)
#228922
Oct 05, 2020 16:23
Swati - Oct 06, 2020 5:11
Im using Episerver forms version - 4.29.2.

What i have noticed that on page load if Nurse is the first value in the dropdown then the textbox is visible, if Doctor is the first value and after page load i change the value from Doctor to Nurse then the textbox is not visible for me.
- Oct 06, 2020 5:54
Swati, can you upgrade Forms to 4.29.3? If yes, then try if that helps with your issue.
Another suggestion is to setup quickly the Alloy MV site and install Forms to it. Then simply create the same form there and see if it works, maybe you spot some mistake?
Swati - Oct 06, 2020 6:32
I have updated the episerver forms to 4.29.3 but still same issue.



- Oct 06, 2020 6:55
Have you checked the bowser console that there are no JavaScript errors on the page? Because if there are then most likely that is the reason why the textbox is not shown.

Otherwise I suggest you create a similar form on the Alloy demo site (because that works if done correctly) and if you get it to work there, compare it to your form having issues.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.