I have a form containing a outsourcing_share
field, it looks something like this:
This how I have defined the form field:
...
def layout(project_data, _):
return html.Div(
[
html.Div(
[
html.P('Budget and development details', className='mb-0 h3'),
html.Small('Questions marked with * are mandatory'),
],
className='mb-3',
),
dbc.Row(
[
dbc.Col(
[
...,
html.Div(
[
html.P(get_label('values2-6'), style=inputStyle),
numeric_input(
'values2-6',
value=project_data.outsourcing_share,
step=10,
prefix='%',
validationRule='percentage',
),
],
className='mb-3',
),
Under the hood, it is using react_components.NumericInput
.
My problem is that, for some reason, even though it allows me to introduce 0 as a valid value, after saving the data, it considers the field to be empty if it has a value of 0.
I have defined the field like this in my project’s model and in Alembic:
outsourcing_share = Column(Integer) # %
sa.Column('outsourcing_share', sa.Integer(), nullable=True),
If I type in a value of 1
for example, it doesn’t think the field is empty.
My question is, how can I make the 0
be taken as a value, not as if the form field was empty.