You’re not receiving notifications from this thread.
Flatpickr with "Present" value as well.
I am currently adding date ranges for jobs in my app. I want the user to pick the start and end dates using flatpickr gem. I also want the user to be able to set the field to "Present" if they are still working there. I was wondering what the best way to implement this would be.
See the screenshots from how LinkedIn do it.
Thanks for your help guys.
- Hide/show the end date field
- Clear the value for the date fields
Flatpickr write the selected value to a form field, so it can be submitted to the server. That's the field you'll want to clear out in the JS.
Then just make sure your end date field is marked as optional in your database so it can be null.
Thanks for your explanation Chris.
Have 3 fields:
Start Date - Date Field
End Date - Date Field
Currently Working - Boolean
If Currenly Working (Boolean) is true; hide End Date field and clear any value from it.
Yep, and I don't know that you necessarily need the currently working boolean in the database. You can just add some methods in your model to delegate to the end_date column.
class Job def currently_working? !end_date? end end
Then you can just use that method to set the
checked attribute on the checkbox by default when editing.