How to manage an optional slot in a form?

Take a look at the dynamic forms description on the forms page. You can customize required_slots for your deadline.