PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / form-builder / blocks / src / blocks / field-select-taxonomy / edit.js

edit.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at form-builder/blocks/src/blocks/field-select-taxonomy/edit.js

45 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { PanelBody, TextControl, SelectControl } from '@wordpress/components';
3 import BaseFieldEdit from '../../components/BaseFieldEdit';
4
5 // Public taxonomies published by the editor bridge (the same set the classic
6 // Manage Fields <select> uses; value = taxonomy slug, label = taxonomy label).
7 // Falls back to an empty list so a missing payload degrades to an empty
8 // control.
9 function getTaxonomyOptions() {
10 const fb = ( typeof window !== 'undefined' && window.wppbFb ) || {};
11 const list = ( fb.selectFields && fb.selectFields.taxonomies ) || [];
12 return Array.isArray( list ) ? list : [];
13 }
14
15 export default function Edit( props ) {
16 const { attributes, setAttributes } = props;
17 const options = getTaxonomyOptions();
18
19 const extraPanels = (
20 <PanelBody title={ __( 'Select (Taxonomy) Settings', 'profile-builder' ) }>
21 <SelectControl
22 label={ __( 'Show Taxonomy Term', 'profile-builder' ) }
23 value={ attributes.taxonomy }
24 options={ options }
25 onChange={ ( val ) => setAttributes( { taxonomy: val } ) }
26 help={ __( 'Terms from this taxonomy will be displayed in the select.', 'profile-builder' ) }
27 />
28 <TextControl
29 label={ __( 'Default Option', 'profile-builder' ) }
30 value={ attributes[ 'default-option' ] }
31 onChange={ ( val ) => setAttributes( { 'default-option': val } ) }
32 help={ __( 'Enter the ID of the default term.', 'profile-builder' ) }
33 />
34 </PanelBody>
35 );
36
37 return (
38 <BaseFieldEdit { ...props } inspectorPanels={ extraPanels }>
39 <select disabled style={ { width: '100%' } }>
40 <option>{ __( '(List of taxonomy terms will be generated here)', 'profile-builder' ) }</option>
41 </select>
42 </BaseFieldEdit>
43 );
44 }
45