There may be an easy way of doing this, but all my attempts to add attributes to an input using input_xxx() has failed.
My use case is adding bootstrap validation by setting the required attribute. It would be nice if something like this could work:
ui.input_text("id", "label", {"required":True})
# TypeError: Invalid type for attribute: <class 'dict'>.
I guess it would not be clear whether such attributes applies to the <form>, <label> or <input> tag, so I'm not really sure what a good api looks like here. This is an okay workaround for simple inputs, but more cumbersome for complex inputs (e.g input_select).
ui.tags.input(
id = "id",
label = "label",
type = "text",
required = True
).get_html_string
# <input id="id" label="label" type="text" required=""/>
I also believe this workaround requires you to use resolve_id(id) manually to make it work in modules?
There may be an easy way of doing this, but all my attempts to add attributes to an input using
input_xxx()
has failed.My use case is adding bootstrap validation by setting the
required
attribute. It would be nice if something like this could work:I guess it would not be clear whether such attributes applies to the
<form>
,<label>
or<input>
tag, so I'm not really sure what a good api looks like here. This is an okay workaround for simple inputs, but more cumbersome for complex inputs (e.ginput_select
).I also believe this workaround requires you to use
resolve_id(id)
manually to make it work in modules?