@@ -102,6 +102,13 @@ const metadata = {
102
102
* <br/><b>Note:</b>
103
103
* Only one radio button can be selected per group.
104
104
*
105
+ * <b>Important:</b> For the <code>name</code> property to have effect when submitting forms, you must add the following import to your project:
106
+ * <code>import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";</code>
107
+ *
108
+ * <b>Note:</b> When set, a native <code>input</code> HTML element
109
+ * will be created inside the <code>ui5-radiobutton</code> so that it can be submitted as
110
+ * part of an HTML form.
111
+ *
105
112
* @type {string }
106
113
* @public
107
114
*/
@@ -110,6 +117,22 @@ const metadata = {
110
117
type : String ,
111
118
} ,
112
119
120
+ /**
121
+ * Defines the form value of the <code>ui5-radiobutton</code>.
122
+ * When a form with a radio button group is submitted, the group's value
123
+ * will be the value of the currently selected radio button.
124
+ *
125
+ * <b>Important:</b> For the <code>value</code> property to have effect, you must add the following import to your project:
126
+ * <code>import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";</code>
127
+ *
128
+ * @type {string }
129
+ * @public
130
+ */
131
+ value : {
132
+ type : String ,
133
+ defaultValue : "" ,
134
+ } ,
135
+
113
136
_label : {
114
137
type : Object ,
115
138
} ,
@@ -170,6 +193,8 @@ class RadioButton extends UI5Element {
170
193
onBeforeRendering ( ) {
171
194
this . syncLabel ( ) ;
172
195
this . syncGroup ( ) ;
196
+
197
+ this . _enableFormSupport ( ) ;
173
198
}
174
199
175
200
syncLabel ( ) {
@@ -198,6 +223,17 @@ class RadioButton extends UI5Element {
198
223
this . _name = this . name ;
199
224
}
200
225
226
+ _enableFormSupport ( ) {
227
+ if ( RadioButton . FormSupport ) {
228
+ RadioButton . FormSupport . syncNativeHiddenInput ( this , ( element , nativeInput ) => {
229
+ nativeInput . disabled = element . disabled || ! element . selected ;
230
+ nativeInput . value = element . selected ? element . value : "" ;
231
+ } ) ;
232
+ } else if ( this . value ) {
233
+ console . warn ( `In order for the "value" property to have effect, you should also: import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";` ) ; // eslint-disable-line
234
+ }
235
+ }
236
+
201
237
onclick ( ) {
202
238
return this . toggle ( ) ;
203
239
}
0 commit comments