-4

I want to show default value as 0.0 in lightning:input field on page load.

I don't want it to be a placeholder.

  • 3
    What you have tried so far? – rahul gawale Dec 30 '19 at 12:24
1

According to SF documentation, it is possible to be done without placeholder, just put default value in value field:

<lightning:input type="number" name="input2" label="Number field with a predefined value" value="0.0"/>
| improve this answer | |
1

Check out this playground to get an sample example of Number field with a predefined value in Lightning Web Component.

enter image description here

value property of lightning-input component specifies the value of an input element.

Reference:- Lightning Web Component Input

if you are dealing with Lightning Data service and want to pre-populate the field value of lightning-input-field, You can again use the value property of it to pre-populate.

         <lightning-record-edit-form
                    id="recordViewForm"
                    record-id="003R00000000000000"
                    record-type-id="012R00000000000000"
                    object-api-name="Contact">
            <lightning-messages></lightning-messages>
            <lightning-input-field field-name="NumberField__c" value="0.0">
            </lightning-input-field>
            <lightning-button type="submit"
                        label="Update record"
                        class="slds-m-top_medium">
            </lightning-button>
        </lightning-record-edit-form>
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.