PluginProbe
WPZOOM Forms – Drag & Drop Contact Form Builder for WordPress / trunk
WPZOOM Forms – Drag & Drop Contact Form Builder for WordPress vtrunk
2.0.9 2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 All 43 releases
wpzoom-forms / src / fields / select / save.js

save.js in WPZOOM Forms – Drag & Drop Contact Form Builder for WordPress trunk, at src/fields/select/save.js

32 lines 949 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useBlockProps, RichText } from '@wordpress/block-editor';
2 import { __ } from '@wordpress/i18n';
3
4 const Save = ( { attributes } ) => {
5 const blockProps = useBlockProps.save();
6 const { id, name, options, defaultValue, label, showLabel, multiple, required } = attributes;
7 const normalizedDefaultValue = options.includes( defaultValue ) ? defaultValue : ( options[0] || '' );
8
9 return <>
10 { showLabel && <label htmlFor={ id }>
11 <RichText.Content
12 tagName="span"
13 value={ label }
14 />
15 { required && <sup className="wp-block-wpzoom-forms-required">{ __( '*', 'wpzoom-forms' ) }</sup> }
16 </label> }
17
18 <select
19 name={ multiple ? `${id}[]` : id }
20 id={ id }
21 required={ !! required }
22 multiple={ !! multiple }
23 defaultValue={ normalizedDefaultValue }
24 { ...blockProps }
25 >
26 { options.map( ( option, index ) => <option key={ index } value={ option }>{ option }</option> ) }
27 </select>
28 </>;
29 };
30
31 export default Save;
32