function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tom Blamire 24Tom Blamire 24 

Error: 'apex:form' component cannot be nested within the form tags

Hi,

I have created (tried) the following VF page but am getting the above error:
 
<apex:page standardController="Opportunity">
  <!-- Page Header -->
  <apex:sectionHeader title="New Opportunity" subtitle="New opportunity for {!Opportunity.Account} " />

  <!-- Opportunity -->
  <apex:form >
    <apex:pageBlock title="Opportunity:" mode="edit">
              <!-- Fields -->
      <apex:pageBlockSection columns="1" showHeader="true" title="Details">
        <apex:inputField value="{!Opportunity.AccountId}" required="true" />
        <apex:inputField value="{!Opportunity.CloseDate}" required="true" />
        <apex:inputField value="{!Opportunity.StageName}"  required="true" />
        <apex:pageBlockSectionItem >
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      <!-- Button Section -->
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Save" action="{!save}" />
        <apex:commandButton value="Cancel" action="{!cancel}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
    
<!-- Product -->
    <apex:sectionHeader title="Products" subtitle="Add Products for {!Opportunity.Name} " />
   <apex:form >
    <apex:pageBlock title="Products:">
     
     
<apex:include pageName="ManageOppProducts"/>
   
  </apex:pageBlock>
    </apex:form>
    

</apex:page>

where am i going wrong???
Best Answer chosen by Tom Blamire 24
pconpcon
Your problem is most likely in the fact that you are using the apex:include to include another Visualforce page.  This page probably has a apex:form tag.  You will need to remove the form tag from there, or move you closing form tag up to around line 20 so that it does surround the apex:include

All Answers

pconpcon
You only need a single apex:form per page really
 
<apex:page standardController="Opportunity">
    <!-- Page Header -->
    <apex:sectionHeader title="New Opportunity" subtitle="New opportunity for {!Opportunity.Account} " />

    <!-- Opportunity -->
    <apex:form >
        <apex:pageBlock title="Opportunity:" mode="edit">
                    <!-- Fields -->
            <apex:pageBlockSection columns="1" showHeader="true" title="Details">
                <apex:inputField value="{!Opportunity.AccountId}" required="true" />
                <apex:inputField value="{!Opportunity.CloseDate}" required="true" />
                <apex:inputField value="{!Opportunity.StageName}"  required="true" />
                <apex:pageBlockSectionItem > </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <!-- Button Section -->
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}" />
                <apex:commandButton value="Cancel" action="{!cancel}" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:sectionHeader title="Products" subtitle="Add Products for {!Opportunity.Name} " />
        <apex:pageBlock title="Products:">
            <apex:include pageName="ManageOppProducts"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Tom Blamire 24Tom Blamire 24
Hi pcon (cool name!)

Unfortunately i am still getting the same error
pconpcon
Your problem is most likely in the fact that you are using the apex:include to include another Visualforce page.  This page probably has a apex:form tag.  You will need to remove the form tag from there, or move you closing form tag up to around line 20 so that it does surround the apex:include
This was selected as the best answer
Tom Blamire 24Tom Blamire 24
you sir are nothing short of a genius!
pconpcon
flattery will get you everywhere :)
Tom Blamire 24Tom Blamire 24
hahaha i really appreciate your help and quickness in helping me - greatly appreciated! :)