.frm_likert_readonly {
pointer-events: none;
}
It does not work on Likert fields - I think because the Likert scale field does not have the attribute read only under field settings. Is there a way to add this functionality even on backend?
The only solution I can think of is to use jQuery to check whether you're in create or update mode and set the pointer-events value accordingly. Put the following in your form's After Fields section in the Customize HTML tab and change 478 to the id of your likert element.
jQuery(document).ready(function($){
"use strict";
var mode = $('input[name="frm_action"]').val();
if ( mode == "update") {
$("#frm_field_478_container").css("pointer-events", "none");
}
});
Grumble. That code should be wrapped in script tags when you put it in the After Fields section
@Rob LeVine , your first suggestion does actually works but in an weird way. I realized that each row in a Likert scale is treated as an unique field with its own field ID. So I have to add ID's of all questions in my Likert scale - about 70 of them!!! Here's how my would look :)
add_filter('frm_setup_edit_fields_vars', 'frm_set_read_only', 20, 3); function frm_set_read_only($values, $field, $entry_id){ // If on the back-end, keep fields editable if ( FrmAppHelper::is_admin() ) { return $values; } // If on front-end, make specific fields read-only if ( in_array( $field->id, array( 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75 ) ) ) { $values['read_only'] = 1; } return $values; }
Here's a tip about another way to do this where you can build your field list dynamically so you don't have to worry about whether you need to change custom code when you add or delete likert fields. All you have to do is use:
if ( $field->type == "likert" )
You can further filter the list by form:
if ( $field->type == "likert" && $field->form_id = "99" ) // change 99 to your form's id
The first example applies to all likert fields on all of your forms. The second example is for a specific form.
Thank for this tip, though I want a selection and not all of the Likert questions as read only on edit. Maybe what would work in my case is maybe filter by Field Key.
Please login or Register to submit your answer