Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions classes/views/frm-forms/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@
</ul>

<?php
$builder_context = array();

foreach ( $values['fields'] ?? array() as $context_field ) {
$builder_context[ $context_field->id ] = array(
'has_rules' => ! empty( $context_field->field_options['adv_logic_rules'] ),
'name' => wp_strip_all_tags( $context_field->name ),
'options' => array_intersect_key(
(array) $context_field->field_options,
array_flip( array( 'hide_field', 'hide_field_cond', 'hide_opt', 'hide_group', 'hide_compare_field', 'hide_compare_measure', 'enable_conditional_logic', 'show_hide', 'any_all', 'calc', 'calc_type', 'admin_only' ) )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this list is duplicated in OPTION_KEYS (js/src/admin/builderContext.js), and the manifest is built inline in a view template.

Two copies of the same 12 keys have to stay in sync by hand; add a key in one place and the badge silently ignores it in the other. The loop that shapes the data also belongs in a helper or controller method rather than the view, which is where the rest of the builder's data prep lives.

Suggested shape: build the array in a helper (for example FrmFormsHelper::get_builder_context( $values['fields'] )) that owns the key list, include the list in the JSON ({ "keys": [...], "fields": {...} }), and have builderContext.js read the keys from it instead of the constant.

),
);
}
wp_print_inline_script_tag(
wp_json_encode( $builder_context, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ),
array(
'id' => 'frm-builder-context',
'type' => 'application/json',
)
);

if ( isset( $values['preview_manifest'] ) ) {
FrmBuilderPreviewHelper::print_manifest( $values['preview_manifest'] );
}
Expand Down
4 changes: 2 additions & 2 deletions css/frm_admin.css

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { validateField } = require( './settings/validateField' );
const { syncFieldOrder, confirmFieldOrderSaved } = require( './fieldOrder' );
const { allowContainerDrop } = require( './fieldPlacement' );
const { getRangeSettingsDefaults, validateNumberRangeSetting, validateStepSetting, validateRangeSettings } = require( './settings/validateRangeSettings' );
const { initBuilderContext } = require( './builderContext' );
const { initBuilderSections } = require( './builderSections' );
const { initFieldListHoverPill } = require( './fieldListHoverPill' );
const { initShowBoxIconSwap } = require( './showBoxIconSwap' );
const { initFieldSizePreview } = require( './fieldSizePreview' );
Expand Down Expand Up @@ -7130,7 +7132,10 @@ window.frmAdminBuildJS = function() {
if ( null !== currentWrapper.querySelector( '.edit_field_type_break' ) ) {
break;
}
$fieldsForPage = $fieldsForPage.add( jQuery( currentWrapper ) );
// Keep the submit row visible when pages are collapsed in the builder.
if ( ! currentWrapper.matches( '.edit_field_type_submit' ) && ! currentWrapper.querySelector( '.edit_field_type_submit' ) ) {
$fieldsForPage = $fieldsForPage.add( jQuery( currentWrapper ) );
}
currentWrapper = currentWrapper.nextElementSibling;
} while ( null !== currentWrapper );

Expand Down Expand Up @@ -12767,6 +12772,7 @@ window.frmAdminBuildJS = function() {

document.querySelectorAll( '.field_type_list > li:not(.frm_show_upgrade):not(.frm_show_update)' ).forEach( makeDraggable );
initFieldListHoverPill();
initBuilderContext( fieldsContainer, initBuilderSections( fieldsContainer ) );
initFieldSizePreview();

jQuery( 'ul.field_type_list, .field_type_list li, ul.frm_code_list, .frm_code_list li, .frm_code_list li a, #frm_adv_info #category-tabs li, #frm_adv_info #category-tabs li a' ).disableSelection();
Expand Down
Loading