You need to sign in to do that
Don't have an account?
John Braun
VisualForce - Dynamic/Conditional page layout
Hi Community,
I'm trying to learn how to build dynamic/conditional page layouts with Visualforce. Specifically, on an edit page, selecting a picklist value and having the VF page auto render a new section of fields. I'm trying to copy an example from the web but keep getting errors when I save my example. Would anyone be willing to take a look at my markup and let me know why it's failing? The error I get is:
Error: VFAgreementPage line 41, column 11: The element type "apex:form" must be terminated by the matching end-tag "</apex:form>"
[Error] Error: The element type "apex:form" must be terminated by the matching end-tag "</apex:form>".
However, I'm sure I do have a end tag for </apex:form>
Please see my code below:
<apex:page standardcontroller="Agreement__c">
<apex:sectionheader title="{!$ObjectType.Agreement__c.label} Edit" subtitle="{!IF(ISNULL(Agreement__c.Name), 'New Agreement',Agreement__c.Name)}"/>
<apex:form >
<apex:pageblock mode="edit" title="{!$ObjectType.Agreement__c.label} Edit" id="thePageBlock">
<apex:pageMessages />
<apex:pageblockbuttons >
<apex:commandbutton value="Save" action="{!Save}"/>
<apex:commandbutton value="Cancel" action="{!Cancel}"/>
</apex:pageblockbuttons>
<apex:actionRegion >
<!-- ********** [Record Type : Product Specific Agreement ] ********** -->
<apex:outputpanel rendered="{!CASESAFEID(Agreement__c.RecordTypeId)='012Z00000009CMCIA2'}">
</apex:outputPanel>
<apex:pageblocksection title="Information" showheader="true" columns="2">
<apex:outputfield value="{!Agreement__c.Name}"/>
<apex:inputfield value="{!Agreement__c.Client__c}" required="true"/>
<apex:outputfield value="{!Agreement__c.RecordTypeId}"/>
<apex:inputfield value="{!Agreement__c.Opportunity__c}" required="true"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Agreement Type"/>
<apex:outputPanel >
<apex:inputfield value="{!Agreement__c.Agreement_Type__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"
status="status"/>
</apex:inputField>
<apex:actionStatus startText="applying value..." id="status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:inputfield value="{!Agreement__c.Status__c}" required="false"/>
</apex:pageblocksection>
</apex:actionRegion>
<apex:pageblocksection title="Term" showheader="true" columns="2">
rendered="{!Agreement__c.Agreement_Type__c == 'DP PDS Project Specific PDS Service Agreement'}">
<apex:inputfield value="{!Agreement__c.Effective_Date__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Auto_Renewal__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Initial_Term_Expiration_Date__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Auto_Renewal_Term__c}" required="false"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:pageblock>
</apex:form>
</apex:page>
I'm trying to learn how to build dynamic/conditional page layouts with Visualforce. Specifically, on an edit page, selecting a picklist value and having the VF page auto render a new section of fields. I'm trying to copy an example from the web but keep getting errors when I save my example. Would anyone be willing to take a look at my markup and let me know why it's failing? The error I get is:
Error: VFAgreementPage line 41, column 11: The element type "apex:form" must be terminated by the matching end-tag "</apex:form>"
[Error] Error: The element type "apex:form" must be terminated by the matching end-tag "</apex:form>".
However, I'm sure I do have a end tag for </apex:form>
Please see my code below:
<apex:page standardcontroller="Agreement__c">
<apex:sectionheader title="{!$ObjectType.Agreement__c.label} Edit" subtitle="{!IF(ISNULL(Agreement__c.Name), 'New Agreement',Agreement__c.Name)}"/>
<apex:form >
<apex:pageblock mode="edit" title="{!$ObjectType.Agreement__c.label} Edit" id="thePageBlock">
<apex:pageMessages />
<apex:pageblockbuttons >
<apex:commandbutton value="Save" action="{!Save}"/>
<apex:commandbutton value="Cancel" action="{!Cancel}"/>
</apex:pageblockbuttons>
<apex:actionRegion >
<!-- ********** [Record Type : Product Specific Agreement ] ********** -->
<apex:outputpanel rendered="{!CASESAFEID(Agreement__c.RecordTypeId)='012Z00000009CMCIA2'}">
</apex:outputPanel>
<apex:pageblocksection title="Information" showheader="true" columns="2">
<apex:outputfield value="{!Agreement__c.Name}"/>
<apex:inputfield value="{!Agreement__c.Client__c}" required="true"/>
<apex:outputfield value="{!Agreement__c.RecordTypeId}"/>
<apex:inputfield value="{!Agreement__c.Opportunity__c}" required="true"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Agreement Type"/>
<apex:outputPanel >
<apex:inputfield value="{!Agreement__c.Agreement_Type__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"
status="status"/>
</apex:inputField>
<apex:actionStatus startText="applying value..." id="status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:inputfield value="{!Agreement__c.Status__c}" required="false"/>
</apex:pageblocksection>
</apex:actionRegion>
<apex:pageblocksection title="Term" showheader="true" columns="2">
rendered="{!Agreement__c.Agreement_Type__c == 'DP PDS Project Specific PDS Service Agreement'}">
<apex:inputfield value="{!Agreement__c.Effective_Date__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Auto_Renewal__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Initial_Term_Expiration_Date__c}" required="false"/>
<apex:inputfield value="{!Agreement__c.Auto_Renewal_Term__c}" required="false"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:pageblock>
</apex:form>
</apex:page>
From your code, i can see you are ending <apex:pageBlock> twice, Following is the code, can you remove one <a/pex:pageBlock> which is third line from the last and save it.
<apex:inputfield value="{!Agreement__c.Auto_Renewal_Term__c}" required="false"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:pageblock>
</apex:page>
Please mark this as best answer if it work to make this community clean and re-usable..Try and let me know if it work for you..
Regards
Sampath Kumar Goud