Skip to content

Commit ec4bd76

Browse files
authored
Merge pull request #358 from suppermancool/Progressive-Registration
Support Working Hours `isRequired`
2 parents a2b3ea7 + 99147ac commit ec4bd76

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

components/Formsy/WorkingHoursSelection.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class WorkingHoursSelection extends React.Component {
5959
startHourValue,
6060
endHourValue,
6161
selectElement,
62-
selectElementProps
62+
selectElementProps,
63+
isRequired
6364
} = this.props
6465

6566
const Select = selectElement || FormsySelect
@@ -82,9 +83,11 @@ class WorkingHoursSelection extends React.Component {
8283
name={startHourName}
8384
onChange={this.onStartHourChange}
8485
value={startHourValue}
86+
required={isRequired}
8587
{...(selectElement && selectElementProps
8688
? selectElementProps
8789
: {})}
90+
validationError={`Please enter ${startHourLabel}`}
8891
/>
8992
</div>
9093

@@ -96,9 +99,11 @@ class WorkingHoursSelection extends React.Component {
9699
name={endHourName}
97100
onChange={this.onEndHourChange}
98101
value={endHourValue}
102+
required={isRequired}
99103
{...(selectElement && selectElementProps
100104
? selectElementProps
101105
: {})}
106+
validationError={`Please enter ${endHourLabel}`}
102107
/>
103108
</div>
104109
</div>
@@ -107,6 +112,12 @@ class WorkingHoursSelection extends React.Component {
107112
}
108113
}
109114

115+
116+
WorkingHoursSelection.defaultProps = {
117+
isRequired: false
118+
}
119+
120+
110121
WorkingHoursSelection.PropTypes = {
111122
startHourLabel: PT.string.isRequired,
112123
endHourLabel: PT.string.isRequired,
@@ -117,6 +128,7 @@ WorkingHoursSelection.PropTypes = {
117128
startHourValue: PT.string,
118129
endHourValue: PT.string,
119130
selectElement: PT.element,
120-
selectElementProps: PT.object
131+
selectElementProps: PT.object,
132+
isRequired: PT.bool
121133
}
122134
export default WorkingHoursSelection

0 commit comments

Comments
 (0)