Skip to main content 3월 5~6일에 샌프란시스코의 TDX 또는 Salesforce+에서 열리는 AI 에이전트 시대를 위한 개발자 컨퍼런스에 참여하세요. 지금 등록하기.
Jeff Gilstrap (Square Feat) 님이 #Visualforce에 질문했습니다
How can a default value be set in a VF page in a long text feild? Currently the default value set in the object feild for comments__c does not populate when the record is entered from the VF page.

 </apex:tab>

                <apex:tab label="Comments" name="CommentsTab" id="tabComments">

                    <apex:pageBlockSection columns="1" id="CommentsPageBlock">

                        <apex:outputField value="{!Inspection__c.Comments__c}" id="Comments" />

                    </apex:pageBlockSection>

                </apex:tab>

 
답변 11개
  1. 2015년 11월 17일 오후 1:55
    In the code you have above, you are using inputTextArea.  You should be using inputField if you want the default value to be presented.  For example

     

    <apex:tab label="Comments" name="CommentsTab" id="tabcomments">

    <apex:pageBlockSection columns="1" id="CommentsPageBlock">

    <apex:inputField value="{!Inspection__c.Comments__c}" id="Comments"/>

    </apex:pageBlockSection>

    </apex:tab>

    If you need to use inputTextArea then you will need to pre-populate the value of Comments__c in your controller with the default value.  You can pull this using the describe methods.
  2. 2015년 11월 20일 오후 11:16
    I created another form for entering data without the comments fieild.  Once record is saved the field populates.  It can be edited using a different form that includes the comments field.   It is a two step process for data entry, not pretty but it is working. Thanks for the help.
  3. 2015년 11월 19일 오전 4:25
    I did find a missing required feild and no longer getting the error. 

    When a new record is created the field in question is blank.It does populate when the record is saved only if no value is entered in the blank field  when a new record is created.  The purpose of the default text is to guide/instruct the user what info to enter - it is rather lengthy.  In order to get the proper instruction, the user must leave the field blank when creating a new record and then go back into edit mode to get the intructions (populated with the default text). Any suggestions on how to get around this?  the same form is being used for NEW and EDIT actions. Am using version 18.0 API.  The VF page would not post - had too many lines to post. 

     
  4. 2015년 11월 18일 오후 8:40
    I have almost the exact same VF page and it works fine for me.  What version of the API are you running?  And you are 100% certian that there are no other required fields that Salesforce could be confusing and not saving the record because of?  Can you provide your entire visualforce page?

     

    <apex:page standardController="Student__c">

    <apex:form >

    <apex:inputField style="width: 300px; height: 300px;" value="{!Student__c.long_text__c}" required="true"/>

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

    </apex:form>

    </apex:page>

     
  5. 2015년 11월 18일 오후 8:08

    save action:

    <apex:pageBlockButtons location="both">

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

    <apex:commandButton action="{!cancel}" value="Cancel" />

    </apex:pageBlockButtons>

    controller:

    <apex:page standardController="Inspection__c" showHeader="true">

     
  6. 2015년 11월 18일 오후 7:21
    Are you using a custom controller on this page or a Standard controller?  Are you using the standard save action or a custom action?
  7. 2015년 11월 18일 오후 7:07
    that code worked great to expand the area but the default value for field is no longer populating in a new record.  Also I am getting an error when tryin to save the record:

    Error:j_id0:inspect:detail:CSPageBlock:j_id34:CS: Validation Error: Value is required.

    It is pointing to this line. 

    <apex:inputField value="{!Inspection__c.Customer__c}" id="customer" required="true" />

    This required customer value is in the form when trying to save...

     
  8. 2015년 11월 18일 오전 12:40
    You can modify the style of the inputField and set the height and width to what you need

     

    <apex:inputField style="width: 300px; height: 300px;" value="{!Inspection__c.Comments__c}" id="Comments" />

  9. 2015년 11월 17일 오후 10:18
    I need a larger area for inputting the data than is available for the standard inputFeild.  Is there a way to resize this input feild in the VF form?  If not I would need more information on where to find the controller since I am a newbee...
  10. 2015년 11월 17일 오전 3:22

    </apex:tab>

    <apex:tab label="Comments" name="CommentsTab" id="tabcomments">

    <apex:pageBlockSection columns="1" id="CommentsPageBlock">

    <apex:inputTextarea cols="200" rows="15" value="{!Inspection__c.Comments__c}" id="Comments"/>

    </apex:pageBlockSection>

    </apex:tab>

    Yes thenk you, InputFeild, above is the code sample.  When a new record is entered from the VF form, the default value set for the feild does not populate the feild in the form. Does the default value need to be included in the code? 
0/9000