Hide fields in form

Martin Shin asked on March 7, 2015 01:34

Hi. Is it possible to hide couple of fields in one form depends from condition in field in another form?

Recent Answers


Brenden Kehren answered on March 7, 2015 03:14

Yes, you can use the visibility macro. For the field that will be the trigger, make sure you have has depending fields (toward the bottom). Then in the field you want to toggle, check the depends on other fields and in the Visibility field, you can enter something like TriggerField.Value == "some value".

1 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on March 9, 2015 06:32

Hello,

you can even specify the Visible condition for entire group of fields (if you want to hide more than one field depending one one condition).

Best regards,
Jan Hermann

1 votesVote for this answer Mark as a Correct answer

Martin Shin answered on March 11, 2015 15:06

Hi Jan. How I can do it?

Martin

1 votesVote for this answer Mark as a Correct answer

Martin Shin answered on March 12, 2015 00:23

Hi Brenden. Your decision works only if fields places in the same table in the same form. I asked about two different forms with different tables.

How can I do it?

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on March 12, 2015 08:29

Hello,

also my solution works only within one form (you simply add a new category and set a macro in its Visible property).

Showing/hiding fields of one form depending on values of other form is not supported scenario and you would need to implement it by yourself. Could you please let me know when this would be useful? Maybe I could come up with some workaround.

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

Martin Shin answered on March 12, 2015 09:04

Hi Jan. Scenario is very simple. I want to hide/show billing address form fields depends from shipping options. For example, if customer selects "express delivery" billing address form fields should be visible. If customer selects something different from "express delivery", billing address form should be hide.

As you can see "Shipping options" and billing address are different web-parts and have different forms and tables.

Martin

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on March 12, 2015 12:37

Hello,

Oh ok, you can simply check what shipping option was selected in the visibility condition:

CurrentShoppingCart.ShoppingCartShippingOption.CodeName!="expressdelivery"

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

Martin Shin answered on March 12, 2015 21:12 (last edited on March 12, 2015 22:15)

Hi Jan. Thank you for decision. It works. But when I try place order at the final step Kentico crushes with error The INSERT statement conflicted with the FOREIGN KEY constraint "FK_COM_Address_AddressCountryID_CMS_Country" ..... column 'CountryID'. I see, that CountryID is required field. I tried to set default numeric value in filed in table, but it returns error also. I'm confused. I don't know how to avoid "country" requirement.

Martin

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on March 17, 2015 13:29

Hello,

by default you don't and you would need to customize it. If you don't need the address you can pass some "dummy" country ID like 287 for example.

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

Ilya Buzytsky answered on May 7, 2016 03:36

Hi, I'd like to return to Brendan's suggestion - but I don't see visibility field in Forms application. Where can I apply macro condition to hide the field? Thanks

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.