Option to block past/future dates (#24)
This commit is contained in:
@@ -152,15 +152,25 @@ class AnswerFormRequest extends FormRequest
|
||||
return ['email:filter'];
|
||||
case 'date':
|
||||
if (isset($property['date_range']) && $property['date_range']) {
|
||||
$this->requestRules[$property['id'].'.*'] = ['date'];
|
||||
return ['array'];
|
||||
$this->requestRules[$property['id'].'.*'] = $this->getRulesForDate($property);
|
||||
return ['array', 'min:2'];
|
||||
}
|
||||
return ['date'];
|
||||
return $this->getRulesForDate($property);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getRulesForDate($property)
|
||||
{
|
||||
if (isset($property['disable_past_dates']) && $property['disable_past_dates']) {
|
||||
return ['date', 'after_or_equal:today'];
|
||||
}else if (isset($property['disable_future_dates']) && $property['disable_future_dates']) {
|
||||
return ['date', 'before_or_equal:today'];
|
||||
}
|
||||
return ['date'];
|
||||
}
|
||||
|
||||
private function getSelectPropertyOptions($property): array
|
||||
{
|
||||
$type = $property['type'];
|
||||
|
||||
@@ -102,6 +102,8 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
'properties.*.use_am_pm' => 'boolean|nullable',
|
||||
'properties.*.date_range' => 'boolean|nullable',
|
||||
'properties.*.prefill_today' => 'boolean|nullable',
|
||||
'properties.*.disable_past_dates' => 'boolean|nullable',
|
||||
'properties.*.disable_future_dates' => 'boolean|nullable',
|
||||
|
||||
// Select / Multi Select field
|
||||
'properties.*.allow_creation' => 'boolean|nullable',
|
||||
|
||||
Reference in New Issue
Block a user