'alphagf_fields', 'text' => $this->get_form_editor_field_title(), 'description' => $this->get_form_editor_field_description(), ); } function get_form_editor_field_settings() { return apply_filters( 'alphagf_unique_id_field_settings', array( 'label_setting', 'admin_label_setting', 'css_class_setting', 'alphagf_unique_id_type', 'alphagf_unique_id_length', 'alphagf_unique_id_start', 'alphagf_unique_id_prefix', 'alphagf_unique_id_suffix', ) ); } /** * The ID is generated after submission, so the field is never shown on the frontend. */ public function get_field_css_class() { return $this->is_form_editor() || $this->is_entry_detail() ? '' : 'gform_hidden'; } public function get_field_content($value, $force_frontend_label, $form) { if (! $this->is_form_editor() && ! $this->is_entry_detail()) { return ''; } return parent::get_field_content($value, $force_frontend_label, $form); } public function get_field_input($form, $value = '', $entry = null) { $form_id = absint($form['id']); $id = (int) $this->id; $field_id = $this->is_entry_detail() || $this->is_form_editor() || 0 == $form_id ? "input_$id" : 'input_' . $form_id . "_$id"; if ($this->is_form_editor()) { return sprintf( "
", esc_attr($field_id), esc_attr__('Generated on submission', 'alpha-addons-for-gravity-forms') ); } if ($this->is_entry_detail_edit()) { return sprintf( "
", $id, esc_attr($field_id), esc_attr($value) ); } return ''; } /** * Ignore posted values on the frontend so the ID can't be supplied by the visitor. */ public function get_value_submission($field_values, $get_from_post_global_var = true) { if ($this->is_entry_detail_edit()) { return parent::get_value_submission($field_values, $get_from_post_global_var); } return ''; } /** * Entries are saved from $_POST directly, so the posted value is discarded here as well. */ public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead) { if ($this->is_entry_detail_edit()) { return parent::get_value_save_entry($value, $form, $input_name, $lead_id, $lead); } return ''; } public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen') { return $format === 'html' ? esc_html($value) : $value; } public function get_value_export($entry, $input_id = '', $use_text = false, $is_csv = false) { return rgar($entry, $input_id ? $input_id : (string) $this->id); } public function sanitize_entry_value($value, $form_id) { return sanitize_text_field($value); } } GF_Fields::register(new ALPHAGF_Unique_ID_Field());