Skip to content
22 changes: 21 additions & 1 deletion classes/helpers/FrmFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,27 @@ public static function get_invalid_error_message( $args ) {
*/
public static function get_success_message( $atts ) {
$message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] );
$message = do_shortcode( FrmAppHelper::use_wpautop( $message ) );

// Only autop if the message includes line breaks.
$autop = strpos( $message, "\n" ) !== false;

/**
* Filters whether to autop the success message.
* This is false by default if the message does not include line breaks.
*
* @since x.x
*
* @param bool $autop
* @param string $message
* @param object $form
*/
$autop = (bool) apply_filters( 'frm_wpautop_success_message', $autop, $message, $atts['form'] );

if ( $autop ) {
$message = FrmAppHelper::use_wpautop( $message );
}

$message = do_shortcode( $message );
$message = '<div class="' . esc_attr( $atts['class'] ) . '" role="status">' . $message . '</div>';
return $message;
}
Expand Down
29 changes: 24 additions & 5 deletions classes/models/FrmFormMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private function maybe_add_to_import_page() {
}

public function import_page() {
$forms = $this->get_forms();
?>
<div class="wrap">
<h2 class="frm-h2"><?php echo esc_html( $this->name ); ?> Importer</h2>
Expand All @@ -66,11 +67,11 @@ public function import_page() {
<input type="hidden" name="action" value="frm_import_<?php echo esc_attr( $this->slug ); ?>" />
<div style="max-width:400px;text-align:left;">
<?php
if ( empty( $this->get_forms() ) ) {
if ( ! $forms ) {
esc_html_e( 'No Forms Found.', 'formidable' );
}
?>
<?php foreach ( $this->get_forms() as $form_id => $name ) { ?>
<?php foreach ( $forms as $form_id => $name ) { ?>
<p>
<label>
<input type="checkbox" name="form_id[]"
Expand All @@ -86,7 +87,20 @@ public function import_page() {
</p>
<?php } ?>
</div>
<p class="submit"><button type="submit" class="button button-primary frm-button-primary">Start Import</button></p>
<?php
$button_atts = array(
'type' => 'submit',
'class' => 'button button-primary frm-button-primary',
);
if ( ! $forms ) {
$button_atts['disabled'] = 'disabled';
}
?>
<p class="submit">
<button <?php FrmAppHelper::array_to_html_params( $button_atts, true ); ?>>
<?php esc_html_e( 'Start Import', 'formidable' ); ?>
</button>
</p>
</form>
<div id="frm-importer-process" class="frm-importer-process frm_hidden">

Expand All @@ -97,8 +111,13 @@ public function import_page() {
</p>

<p class="process-completed" class="frm_hidden">
The import process has finished! We have successfully imported
<span class="forms-completed"></span> forms. You can review the results below.
<?php
printf(
// translators: %s is the number of forms that were imported.
esc_html__( 'The import process has finished! We have successfully imported %s forms. You can review the results below.', 'formidable' ),
'<span class="forms-completed"></span>'
);
?>
</p>

<div class="status"></div>
Expand Down
6 changes: 5 additions & 1 deletion css/custom_theme.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,12 @@
}

.with_frm_style .frm_message p {
margin-bottom: 5px;
color: var(--success-text-color)<?php echo esc_html( $important ); ?>;
margin-bottom: 0;
}

.with_frm_style .frm_message > p:first-of-type {
margin-top: 0;
}

.with_frm_style .frm_message,
Expand Down
32 changes: 16 additions & 16 deletions tests/cypress/e2e/Forms/fieldsInFormBuilder.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Fields in the form builder", () => {

cy.get('h1 > .frm_bstooltip').should("contain", "Test Form");
cy.get('.current_page').should("contain", "Build");
cy.get('.frm_field_list > #frm-nav-tabs > .frm-tabs > #frm_insert_fields_tab').should("contain", "Add Fields");
cy.xpath("//li[@class='frm-active']//a[@id='frm_insert_fields_tab']").should("contain", "Add Fields");

cy.log("Create and duplicate fields for each type");
const fieldsToDelete = [
Expand Down Expand Up @@ -69,7 +69,7 @@ describe("Fields in the form builder", () => {


it("should rename a field from each type", () => {

const createField = (fieldId, fieldType) => {
cy.log(`Create a ${fieldType} field`);
cy.get(`li[id="${fieldId}"] a[title="${fieldType}"]`).click({ force: true });
Expand Down Expand Up @@ -121,7 +121,7 @@ describe("Fields in the form builder", () => {
cy.log(`Set ${fieldType} field as require`);
cy.get(`li[data-ftype="${fieldId}"] [id^="field_"][id$="_inner_container"] > .frm-field-action-icons > .dropdown > .frm_bstooltip > .frmsvg > use`, { timeout: 10000 }).click({ force: true });
cy.get(`li[data-ftype="${fieldId}"] .frm_select_field > span`).should("contain", "Field Settings").click({ force: true });
cy.get('.frm_field_list div[id^="frm-single-settings-"] .frm_grid_container .frm-hide-empty input[type="checkbox"]', { timeout: 10000 }).check({ force: true });
cy.get('input.frm_req_field[type="checkbox"]').check({ force: true });
};

cy.openForm();
Expand All @@ -145,7 +145,7 @@ describe("Fields in the form builder", () => {
});

cy.log("Update form");
cy.get('#frm_submit_side_top').should("contain", "Update").click();
cy.get('#frm_submit_side_top').should("contain", "Update").click({force: true});

cy.log("Click on Preview - Blank Page");
cy.get("#frm-previewDrop",{timeout:5000}).should("contain", "Preview").click();
Expand Down Expand Up @@ -177,10 +177,10 @@ describe("Fields in the form builder", () => {
cy.log("Navigate back to the formidable form page");
cy.go(-2);
});

it("should validate forms with javascript setting", () => {

cy.openForm();
cy.openForm();
cy.log(`Create a text field and set it as required`);
cy.get(`li[id="text"] a[title="Text"]`).click({ force: true });
cy.get(`li[data-ftype="text"] [id^="field_"][id$="_inner_container"] > .frm-field-action-icons > .dropdown > .frm_bstooltip > .frmsvg > use`, { timeout: 10000 }).click({ force: true });
Expand All @@ -190,10 +190,10 @@ describe("Fields in the form builder", () => {
cy.log("Create a phone and email field");
cy.get(`li[id="email"] a[title="Email"]`).click({ force: true });
cy.get(`li[id="phone"] a[title="Phone"]`).click({ force: true });

cy.log("Update form");
cy.get('#frm_submit_side_top').should("contain", "Update").click();
cy.get('#frm_submit_side_top').should("contain", "Update").click({force: true});

cy.log("Enabling the 'Validate this form with javascript' setting");
cy.xpath("//ul[@class='frm_form_nav']//a[contains(text(),'Settings')]").should("contain","Settings").click();
cy.get(':nth-child(3) > td > .frm_inline_block',{timeout:5000}).should("contain","Validate this form with javascript");
Expand All @@ -215,7 +215,7 @@ describe("Fields in the form builder", () => {
cy.get(`[id^="frm_error_field_"]`).eq(0).should("contain",`Text cannot be blank.`);
cy.get(`[id^="frm_error_field_"]`).eq(1).should("contain",`Email is invalid`);
cy.get(`[id^="frm_error_field_"]`).eq(2).should("contain",`Phone is invalid`);
cy.get("button[type='submit']").should("contain", "Submit").click();
cy.get("button[type='submit']").should("contain", "Submit").click();

cy.log("Navigate back to the formidable form page");
cy.go('back');
Expand All @@ -236,17 +236,17 @@ describe("Fields in the form builder", () => {
cy.get(`[id^="frm_error_field_"]`).eq(1).should("not.exist");
cy.get(`[id^="frm_error_field_"]`).eq(2).should("not.exist");
cy.get('[id^="field_"]').filter('input, textarea').eq(1).clear();
cy.get('[id^="field_"]').filter('input, textarea').eq(2).clear();
cy.get("button[type='submit']").should("contain", "Submit").click();
cy.get('[id^="field_"]').filter('input, textarea').eq(2).clear();
cy.get("button[type='submit']").should("contain", "Submit").click();

cy.log("Navigate back to the formidable form page");
cy.go('back');
});
});

afterEach(() => {

cy.log("Teardown - Save the form and delete it");
cy.get("a[aria-label='Close']", { timeout: 5000 }).click({ force: true });
cy.deleteForm();
cy.get("a[aria-label='Close']", { timeout: 5000 }).click({ force: true });
cy.deleteForm();
});
});
6 changes: 3 additions & 3 deletions tests/cypress/e2e/Forms/formsSettings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ describe("Updating form settings", () => {
cy.get("button[type='submit']").should("contain", "Submit").click();

cy.log("Verify URL redirect after submitting form");
cy.origin('https://formidableforms.com', ()=> {
cy.location('href').should('include', 'https://formidableforms.com/')
});
cy.origin('https://formidableforms.com', () => {
cy.location('href', { timeout: 10000 }).should('include', 'formidableforms.com');
});

cy.log("Navigate back to the formidable form page");
cy.visit(Origin + "/wp-admin/admin.php?page=formidable");
Expand Down
11 changes: 6 additions & 5 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ Cypress.Commands.add("openForm", () => {

cy.get('h1 > .frm_bstooltip').should("contain", "Test Form");
cy.get('.current_page').should("contain", "Build");
cy.get('.frm_field_list > #frm-nav-tabs > .frm-tabs > #frm_insert_fields_tab').should("contain", "Add Fields");
cy.xpath("//li[@class='frm-active']//a[@id='frm_insert_fields_tab']").should("contain", "Add Fields");

});

Cypress.Commands.add("getCurrentFormattedDate", () => {
const currentDate = new Date();
const formattedDate = currentDate.toISOString().split('T')[0].replace(/-/g, '/');
return formattedDate;
});
});

Cypress.Commands.add("emptyTrash", () => {
cy.log("Precondition - Clear trash if there are deleted forms in the list");
cy.get('.subsubsub > .trash > a').then(($trashLink) => {
if ($trashLink.text().includes("Trash")) {
cy.wrap($trashLink).click();
cy.wrap($trashLink).click();
cy.get('body').then($body => {
if ($body.find('#delete_all').length > 0) {
cy.get('#delete_all').should("contain", "Empty Trash").click();
Expand All @@ -90,5 +91,5 @@ cy.get('.subsubsub > .trash > a').then(($trashLink) => {
} else {
cy.log('No forms in the Trash.');
}
});
});
});
});
8 changes: 4 additions & 4 deletions tests/phpunit/forms/test_FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ public function run_message_after_create( $show_form = 0 ) {
$this->assertNotEmpty( $created_entry, 'No entry found with key ' . $entry_key );

$response = FrmFormsController::show_form( $form->id ); // this is where the message is returned
$this->assertNotFalse( strpos( $response, '<div class="frm_message" role="status"><p>Done!</p>' ) );
$this->assertNotFalse( strpos( $response, 'frmFrontForm.scrollMsg(' . $form->id . ')' ) );
$this->assertStringContainsString( '<div class="frm_message" role="status">Done!</div>', $response );
$this->assertStringContainsString( 'frmFrontForm.scrollMsg(' . $form->id . ')', $response );

if ( $show_form ) {
$this->assertNotFalse( strpos( $response, '<input type="hidden" name="form_id" value="' . $form->id . '" />' ) );
$this->assertStringContainsString( '<input type="hidden" name="form_id" value="' . $form->id . '" />', $response );
} else {
$this->assertFalse( strpos( $response, '<input type="hidden" name="form_id" value="' . $form->id . '" />' ) );
$this->assertStringNotContainsString( '<input type="hidden" name="form_id" value="' . $form->id . '" />', $response );
}
}

Expand Down
Loading