Checking the value of field

By: Robert Cabiya-an | Asked: 08/05/2024
ForumsCategory: General questionsChecking the value of field
Robert Cabiya-an asked 5 months ago
Hello. I have a snippet that will make a field read only base on the value of another field on the same form   add_filter(\'frm_setup_new_fields_vars\', \'frm_set_read_only_on_create\', 9, 2);
add_filter(\'frm_setup_edit_fields_vars\', \'frm_set_read_only_on_create\', 9, 2);
function frm_set_read_only_on_create( $values, $field ){  $entry_id = FrmAppHelper::get_param(\'id\', 0, \'get\'); // Get the entry ID from the URL     $text_field_id = 805; // ID of the text field to check     $text_field_value = FrmEntryMeta::get_entry_meta_by_field($entry_id, $text_field_id, true);     if ($text_field_value == 5) {          $readonly_fields = array(409); // IDs of the text fields to make read-only         if (in_array($field->id, $readonly_fields)) {             $values[\'read_only\'] = true;         }     }     return $values;   }     The code is working fine during the edit mode and after submitting the form the code works fine. The problem is when i open the form using the editlink shortchode, the code is not applying the read only even the value of the field is equal to 5.    Can you help what am i missing. Thanks.      
1 Answers
Rob LeVineRob LeVine answered 5 months ago
I suggest putting debug code into the function (or using the Kint debugger) to see what the values are in the function. My guess is that FrmAppHelper::get_param('id', 0, 'get') is not returning the value you think it is.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right