Form Component CustomAutopostHandling Doesnt Work

Laura Frese asked on February 4, 2021 00:08

I created a category tree selector form component to allow people to select categories in a form. Every time a checkbox is checked it would do a post and the checkbox selections would disappear. I wanted to prevent this auto post so I added

// Disables automatic server-side evaluation for the component
public override bool CustomAutopostHandling => true;

To my form component code as detailed here https://docs.xperience.io/k12sp/developing-websites/form-builder-development/developing-form-components/example-developing-a-custom-form-component and here https://docs.xperience.io/k12sp/developing-websites/form-builder-development/developing-form-components

link text

However this does not actually work to prevent the post.

Correct Answer

Laura Frese answered on February 4, 2021 00:10

To get around this issue, add the "data-ktc-notobserved-element" attribute to the input field in the view.

IDictionary<string, object> htmlAttributes = ViewData.GetEditorHtmlAttributes();
htmlAttributes["data-ktc-notobserved-element"] = "";

or

<input type="checkbox" data-ktc-notobserved-element id="@cat.CategoryName" name="cat" value="@cat.CategoryName">
0 votesVote for this answer Unmark Correct answer

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