Is there a way to create a TextBox of a type different than what is offered in design mode? Just changing the type dynamically won’t work.
I guess I could change this from js, but why not just create the input field of a type that is passed to the constructor? Almost any browser will offer a nice input gadget based on type.
from anvil import *
class Playground(PlaygroundTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
number_box = TextBox(type='text')
self.add_component(number_box)
number_box.type = 'number'
print(number_box.type) # number, works as expeted
# result input is of type 'number'
# <input type="number" class="form-control to-disable anvil-text-box anvil-spacing-above-small anvil-spacing-below-small align-left belongs-to-INLLIM anvil-component" placeholder="" style="text-align: left;">
time_box = TextBox(type='text')
self.add_component(time_box)
time_box.type = 'time'
print(time_box.type) # time, does not work as expeted
# result input is of type 'text'
# <input type="text" class="form-control to-disable anvil-text-box anvil-spacing-above-small anvil-spacing-below-small align-left belongs-to-INLLIM anvil-component" placeholder="" style="text-align: left;">
real_time_box = TextBox(type='time')
self.add_component(real_time_box)
print(real_time_box.type) # BUMMER!
# result input is of type 'text'
# <input type="text" class="form-control to-disable anvil-text-box anvil-spacing-above-small anvil-spacing-below-small align-left belongs-to-INLLIM anvil-component" placeholder="" style="text-align: left;">