0

I have a visualforce page to create a record. I use SLDS. Problem is, when i try to save record with filled form, the inserted data is not binded with new record. note: I use a standard controller

example of my form field:

<apex:form>
   <apex:pageBlockSectionItem>
            <div class="slds-form-element slds-m-bottom--small">
              <label class="slds-form-element__label" for="buildingName">
                <abbr class="slds-required"
                      title="required"><b>*</b></abbr>{!$ObjectType.Building__c.fields.Name.Label}
              </label>
              <div class="slds-form-element__control">
                <!--<apex:inputField value="{!Building__c.Name}" />-->
                <input type="text" id="buildingName" class="slds-input" value="{!Building__c.Name}"/>
              </div>
            </div>
          </apex:pageBlockSectionItem>

         <apex:commandButton action="{!save}" value="Save" id="saveButton"/>
</apex:form>

but when i use <apex:inputField value="{!Building__c.Name}" />, instead of SLDS <input>, my record will be successfuly saved with inserted name. Usind SLDS, all fields will be blank on new record, except required field which will be auto populated with some random id i quess.

2 Answers 2

2

SLDS is only a Design System catering to the UX needs.

The Lightning Design System enables you to build rich enterprise experiences and custom applications with the patterns and established best practices that are native to Salesforce.

Using it, does not bind any variables on the form directly to the field on the object. input component only helps you to capture values on the form itself, but to able to persist it, you need to have additional controllers to it. SLDS on input field just adds design element and not any operational element. SLDS input is inherited by lightning:input (in beta), and you can find more information about it on the documentation.

apex:inputField on other hand directly binds the values from the object's field. And that's why you are able to save it directly.

2
  • So i tried to make controller extension, but i am stuck with how to get the input values to apex controller to create and insert new record. I tried this: <input type="text" id="buildingName" class="slds-input" value="{!building.Name}"/> And in my controller extension: I have ` public Building__c building {get; set;}` And public PageReference save() where i insert building; This is not working for me, and how i bind this save method to my: <button class="slds-button slds-button_brand" action="{!save}" >Save</button>
    – RSICK
    Commented Apr 19, 2018 at 8:37
  • Go through visualforce documentation and trailheads, it has enough information on how to get this done.
    – Jayant Das
    Commented Apr 19, 2018 at 11:57
0

Input is HTML tag so binding value to html tag will not work, use apex:inputfield to bind value to it. it will work for sure.

hope this helps.

1
  • I need to use lightning design look and feel. Cant use apex:inputfield for that,
    – RSICK
    Commented Apr 19, 2018 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .