How do I add a conditional logic to a custom widget?