MC4WP_Form_Element::get_response_html PHP Method

get_response_html() public method

Gets the form response string
public get_response_html ( boolean $force_show = false ) : string
$force_show boolean
return string
    public function get_response_html($force_show = false)
    {
        $html = '';
        $form = $this->form;
        if ($this->is_submitted || $force_show) {
            foreach ($this->form->messages as $key) {
                $html .= $this->get_message_html($key);
            }
        }
        /**
         * Filter the form response HTML
         *
         * Use this to add your own HTML to the form response. The form instance is passed to the callback function.
         *
         * @since 3.0
         *
         * @param string $html The complete HTML string of the response, excluding the wrapper element.
         * @param MC4WP_Form $form The form object
         */
        $html = (string) apply_filters('mc4wp_form_response_html', $html, $form);
        // wrap entire response in div, regardless of a form was submitted
        $html = '<div class="mc4wp-response">' . $html . '</div>';
        return $html;
    }

Usage Example

 /**
  * Returns the form response
  *
  * @return string
  */
 public function get_form_response()
 {
     if ($this->form_element instanceof MC4WP_Form_Element) {
         return $this->form_element->get_response_html();
     }
     return '';
 }