emailConfirmEnabled ) { return parent::get_field_container_tag( $form ); } return 'fieldset'; } /** * Whether this field expects an array during submission. * * @since 2.4 * * @return bool */ public function is_value_submission_array() { return (bool) $this->emailConfirmEnabled ; } public function validate( $value, $form ) { $email = is_array( $value ) ? rgar( $value, 0 ) : $value; // Form objects created in 1.8 will supply a string as the value. $is_blank = rgblank( $value ) || ( is_array( $value ) && rgempty( array_filter( $value ) ) ); if ( ! $is_blank && ! GFCommon::is_valid_email( $email ) ) { $this->failed_validation = true; $this->validation_message = empty( $this->errorMessage ) ? esc_html__( 'The email address entered is invalid, please check the formatting (e.g. email@domain.com).', 'gravityforms' ) : $this->errorMessage; } elseif ( $this->emailConfirmEnabled && ! empty( $email ) ) { $confirm = is_array( $value ) ? rgar( $value, 1 ) : $this->get_input_value_submission( 'input_' . $this->id . '_2' ); if ( $confirm != $email ) { $this->failed_validation = true; $this->validation_message = esc_html__( 'Your emails do not match.', 'gravityforms' ); } } } public function get_field_input( $form, $value = '', $entry = null ) { $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); if ( is_array( $value ) ) { $value = array_values( $value ); } $form_id = absint( $form['id'] ); $id = absint( $this->id ); $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id"; $form_id = ( $is_entry_detail || $is_form_editor ) && empty( $form_id ) ? rgget( 'id' ) : $form_id; $size = $this->size; $disabled_text = $is_form_editor ? "disabled='disabled'" : ''; $class_suffix = $is_entry_detail ? '_admin' : ''; $class = $this->emailConfirmEnabled ? '' : $size . $class_suffix; //Size only applies when confirmation is disabled $class = esc_attr( $class ); $form_sub_label_placement = rgar( $form, 'subLabelPlacement' ); $field_sub_label_placement = $this->subLabelPlacement; $is_sub_label_above = $field_sub_label_placement == 'above' || ( empty( $field_sub_label_placement ) && $form_sub_label_placement == 'above' ); $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : ''; $html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text'; $required_attribute = $this->isRequired ? 'aria-required="true"' : ''; $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"'; $aria_describedby = $this->get_aria_describedby(); $enter_email_field_input = GFFormsModel::get_input( $this, $this->id . '' ); $confirm_field_input = GFFormsModel::get_input( $this, $this->id . '.2' ); $enter_email_label = rgar( $enter_email_field_input, 'customLabel' ) != '' ? $enter_email_field_input['customLabel'] : esc_html__( 'Enter Email', 'gravityforms' ); $enter_email_label = gf_apply_filters( array( 'gform_email', $form_id ), $enter_email_label, $form_id ); $confirm_email_label = rgar( $confirm_field_input, 'customLabel' ) != '' ? $confirm_field_input['customLabel'] : esc_html__( 'Confirm Email', 'gravityforms' ); $confirm_email_label = gf_apply_filters( array( 'gform_email_confirm', $form_id ), $confirm_email_label, $form_id ); $single_placeholder_attribute = $this->get_field_placeholder_attribute(); $enter_email_placeholder_attribute = $this->get_input_placeholder_attribute( $enter_email_field_input ); $confirm_email_placeholder_attribute = $this->get_input_placeholder_attribute( $confirm_field_input ); $single_autocomplete_attribute = $this->get_field_autocomplete_attribute(); $enter_email_autocomplete_attribute = $this->get_input_autocomplete_attribute( $enter_email_field_input ); $confirm_email_autocomplete_attribute = $this->get_input_autocomplete_attribute( $confirm_field_input ); if ( $is_form_editor ) { $single_style = $this->emailConfirmEnabled ? "style='display:none;'" : ''; $confirm_style = $this->emailConfirmEnabled ? '' : "style='display:none;'"; if ( $is_sub_label_above ) { return "