Skip to content

Commit f089ca5

Browse files
committed
feat(TimePicker): add the ability to set a custom name attribute for the input element
1 parent 376d238 commit f089ca5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/content/forms/time-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const timePickerList = timePickerElementList.map(timePickerEl => {
173173
| `inputReadOnly` | boolean | `false` | Toggle the readonly state for the component. |
174174
| `invalid` | boolean | `false` | Toggle the invalid state for the component. |
175175
| `locale` | string | `'default'` | Sets the default locale for components. If not set, it is inherited from the navigator.language. |
176+
| `name` | string | `null` | Set the name attribute for the input element. |
176177
| `placeholder` | string | `'Select time'` | Specifies a short hint that is visible in the input. |
177178
| `size` | `'sm'` \| `'lg'` | `null` | Size the component small or large. |
178179
| `time` | date \| string \| null | `null` | Default value of the component |

js/src/time-picker.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const Default = {
8484
inputReadOnly: false,
8585
invalid: false,
8686
locale: 'default',
87+
name: null,
8788
placeholder: 'Select time',
8889
required: true,
8990
size: null,
@@ -105,6 +106,7 @@ const DefaultType = {
105106
inputReadOnly: 'boolean',
106107
invalid: 'boolean',
107108
locale: 'string',
109+
name: 'string',
108110
placeholder: 'string',
109111
required: 'boolean',
110112
size: '(string|null)',
@@ -334,8 +336,8 @@ class TimePicker extends BaseComponent {
334336
inputEl.type = 'text'
335337
inputEl.value = this._date ? this._date.toLocaleTimeString(this._config.locale) : ''
336338

337-
if (this._element.id) {
338-
inputEl.name = `time-picker-${this._element.id}`
339+
if (this._config.name || this._element.id) {
340+
inputEl.name = this._config.name || `time-picker-${this._element.id}`
339341
}
340342

341343
const events = ['change', 'keyup', 'paste']

0 commit comments

Comments
 (0)