Clear a field in a Record Edit form

I have a record that has a “Latest Status” paragraph text field, which is a required field.

When my users Edit the record, I want to clear that field - thus requiring them to enter a new “Latest Status”.

How can I clear a single field when displaying the Edit Form?

Hey there!

To clear the field when a form is submitted, you’ll want to use your form’s record rules. This should still work even if your paragraph text field is required.

1. In the builder, navigate to your Edit Form’s Rules
Screen Shot 2021-08-18 at 8.19.34 AM

2. Choose your field and set a custom value to blank text
Screen Shot 2021-08-18 at 8.21.11 AM

Now when a user submits the edit form, the value for your paragraph field will get cleared.

Thanks,
Taylor Wise

1 Like

Hi Taylor.

Thanks for the suggestion. However what I’m looking for is a way to cleat the field before the form is submitted. As the field is required, this will force the user to update it.

I’ve also tried doing this using Javascript with no success - see here

Ah I see. My apologies.

For safekeeping, I would keep the view identifier in there, just in case the field ID is displayed anywhere behind the modal.

The below will help ensure the only thing that gets cleared is your form input value.

What you got to work:

  $('#field_45').val('');

The code to only clear your form input value:

  $('#view_19 #field_45').val('');
2 Likes

Very useful, thanks @TaylorWise !!

So that’s the way to do it for a text field. It works fine and very useful.
$(document).on(‘knack-view-render.view_2232’, function(event, view, data) {
$(‘#view_2232 #field_702’).val(‘’);
});

@TaylorWise , how to adapt it for UNchecking ckeckboxs (multiple choice) after submiting the form?

$(document).on(‘knack-view-render.view_2232’, function(event, view, data) {
    $(‘#view_2232 #field_702’).val(‘’);
    $(‘#view_2232 #field_XXX’).prop("checked", false);
});

Give this a try!

Hi @TaylorWise , I tried it this morning and could not make it work. :thinking: