'field', 'type' => 'text', 'label' => __( 'Text', 'booking' ), 'icon' => 'wpbc_icn_text_fields', 'usage_key' => 'text', // Optional: used by UsageLimitService if you set limits elsewhere. // === Schema: coercion/validation + defaults for Inspector/serialization ===. 'schema' => array( 'props' => array( 'label' => array( 'type' => 'string', 'default' => __( 'Text', 'booking' ) ), 'name' => array( 'type' => 'string', 'default' => '' ), 'html_id' => array( 'type' => 'string', 'default' => '' ), 'placeholder' => array( 'type' => 'string', 'default' => '' ), 'required' => array( 'type' => 'boolean', 'default' => false ), 'minlength' => array( 'type' => 'number', 'default' => null, 'min' => 0 ), 'maxlength' => array( 'type' => 'number', 'default' => null, 'min' => 0 ), 'pattern' => array( 'type' => 'string', 'default' => '' ), 'cssclass' => array( 'type' => 'string', 'default' => '' ), 'help' => array( 'type' => 'string', 'default' => '' ), 'default_value' => array( 'type' => 'string', 'default' => '' ), ), ), // === Inspector UI (Factory-driven; no WP templates here) ===. 'inspector_ui' => array( 'title' => __( 'Single Line Text', 'booking' ) . '', // TODO remove it. 'description' => __( 'Configure a single-line text input.', 'booking' ), 'header_variant' => 'toolbar', 'header_actions' => array( 'deselect', 'scrollto', 'move-up', 'move-down', 'duplicate', 'delete' ), 'groups' => array( array( 'key' => 'basic', 'label' => __( 'Basic', 'booking' ), 'open' => true, 'controls' => array( array( 'type' => 'text', 'key' => 'label', 'label' => __( 'Label', 'booking' ) ), array( 'type' => 'text', 'key' => 'name', 'label' => __( 'Name', 'booking' ) ), array( 'type' => 'text', 'key' => 'placeholder', 'label' => __( 'Placeholder', 'booking' ) ), array( 'type' => 'checkbox', 'key' => 'required', 'label' => __( 'Required', 'booking' ) ), array( 'type' => 'text', 'key' => 'default_value', 'label' => __( 'Default value', 'booking' ) ), array( 'type' => 'textarea', 'key' => 'help', 'label' => __( 'Help text', 'booking' ), 'rows' => 3, ), ), ), array( 'key' => 'validation', 'label' => __( 'Validation', 'booking' ), 'controls' => array( array( 'type' => 'number', 'key' => 'minlength', 'label' => __( 'Min length', 'booking' ) ), array( 'type' => 'number', 'key' => 'maxlength', 'label' => __( 'Max length', 'booking' ) ), // array( 'type' => 'text', 'key' => 'pattern', 'label' => __( 'Pattern', 'booking' ) ), // Temporary comment pattern, it can be enabled in future updates. ), ), array( 'key' => 'appearance', 'label' => __( 'Appearance', 'booking' ), 'controls' => array( array( 'type' => 'text', 'key' => 'cssclass', 'label' => __( 'CSS class', 'booking' ) ), array( 'type' => 'text', 'key' => 'html_id', 'label' => __( 'HTML ID', 'booking' ) ), ), ), ), ), // No templates_printer for Schema-driven variant. ); return $packs; } add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_text_schema' ); /** * Enqueue the Text field pack JS for the Builder page. * * This hook is fired only on the Builder page (gated by is_builder_by_request()), * so we do not need an extra $page check here. * * @param string $page Current admin page slug. * * @return void */ function wpbc_bfb_enqueue__field_text_schema_js( $page ) { wp_enqueue_script( 'wpbc-bfb_field_text_schema', wpbc_plugin_url( '/includes/page-form-builder/field-packs/text/_out/field-text.js' ), array( 'wpbc-bfb' ), WP_BK_VERSION_NUM, true ); } add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_text_schema_js', 10, 1 ); /** * (Optional) Register the "Text" palette item in "general/bottom". * * If your palette auto-builds from packs, you can remove this. * Keeping it here makes the reference self-contained and explicit. * * @param string $group Palette group: 'general' | 'advanced' | ... * @param string $position Position: 'top' | 'bottom' * * @return void */ function wpbc_bfb_palette_register_items__text_schema( $group, $position ) { if ( 'standard' !== $group || 'bottom' !== $position ) { return; } ?>
  • text