Support #14567
openWt4.12.6 Wt::WLineEdit with bootstrap v5 html input with class="form-control" needs disabled for grayed out appearance
0%
Description
https://getbootstrap.com/docs/5.2/forms/form-control/ says that "Add the disabled boolean attribute on an input to give it a grayed out appearance".
I was using the method setReadOnly which adds readonly="readonly" but does add the bootstrap "disabled".
Do I need to change my code?
For testing I added manually disabled and now it was grayed.
Updated by robs j 11 days ago
https://getbootstrap.com/docs/5.2/forms/form-control/ says that "Add the disabled boolean attribute on an input to give it a grayed out appearance".
I was using the method setReadOnly which adds readonly="readonly" but does add the bootstrap "disabled".
Do I need to change my code?
For testing I added manually disabled and now it was grayed.
Hiding the element with method setEnabled(bool) has to be done via class="d-none" or style="display: none;" instead of setting "disabled".
But buttons seems to be handled correctly.
todo
Updated by Romain Mardulyn 7 days ago
Hi robs,
I am not sure to understand what your issue is, but here is what I can tell you.
WLineEdit::setReadOnly(true) will make the WLineEdit uneditable, but will change its color to gray (this was is the case for bootstrap 2 and 3 due to haw it handles uneditable widgets).
WLineEdit::setEnable(false) or WLineEdit::setDisable(true) will disable the widget, rendering it uneditable and preventing it from being focussed. In that case it will be grayed out.
WLineEdit::hide() or WLineEdit::setHidden(true) will hide the WLineEdit by setting its display to none.
Updated by Romain Mardulyn 5 days ago
I am sorry, I made a mistake in the first statement.
It should have been:
WLineEdit::setReadOnly(true) will make the WLineEdit uneditable, but will NOT change its color to gray (this was is the case for bootstrap 2 and 3 due to haw it handles uneditable widgets).
This is a change from Bootstrap, not Wt. You can see it here: https://getbootstrap.com/docs/5.3/forms/form-control/#readonly