From 0f964d09386af2bee11f5d54d33d295d87575b4b Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:28:53 +0300 Subject: [PATCH 1/3] Add css classes to summary field --- classes/models/FrmFieldFormHtml.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index 5dd91fe877..d2c12de3bd 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -436,6 +436,9 @@ private function add_field_div_classes() { } $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); + if ( $this->field_obj->get_field_column( 'type' ) === 'summary' ) { + $this->html = str_replace( ' form-field', esc_attr( ' form-field' . $classes ), $this->html ); + } } /** From 8c630eed065354205b516c2d3529e9dfae7b65bb Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:37:18 +0300 Subject: [PATCH 2/3] Return early after adding css classes to summary field --- classes/models/FrmFieldFormHtml.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index d2c12de3bd..18b76336b6 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -435,10 +435,11 @@ private function add_field_div_classes() { $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . esc_attr( $classes ), $this->html ); } - $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); if ( $this->field_obj->get_field_column( 'type' ) === 'summary' ) { $this->html = str_replace( ' form-field', esc_attr( ' form-field' . $classes ), $this->html ); + return; } + $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); } /** From faff405836971efb22688e70c0c40a40f2822e2b Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:52:31 +0300 Subject: [PATCH 3/3] Reuse existing code just adding a new condition --- classes/models/FrmFieldFormHtml.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index 18b76336b6..ec797e51d8 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -430,15 +430,12 @@ private function replace_entry_key() { private function add_field_div_classes() { $classes = $this->get_field_div_classes(); - if ( $this->field_obj->get_field_column( 'type' ) === 'html' && strpos( $this->html, '[error_class]' ) === false ) { + if ( in_array( $this->field_obj->get_field_column( 'type' ), array( 'html', 'summary' ), true ) && strpos( $this->html, '[error_class]' ) === false ) { // there is no error_class shortcode for HTML fields $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . esc_attr( $classes ), $this->html ); - } - - if ( $this->field_obj->get_field_column( 'type' ) === 'summary' ) { - $this->html = str_replace( ' form-field', esc_attr( ' form-field' . $classes ), $this->html ); return; } + $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); }