I'm trying to remove an apex form object from my visualforce page. All it does is wrap a commandButton like so:

<apex:form > <apex:commandButton value="customAction" action="{!customAction}"/> </apex:form>

Is there an alternate way to have a button that fires a controller action?

  • 1
    This is just the same question as this one, no?
    – Adrian Larson
    Jul 22, 2016 at 16:35
  • @AdrianLarson I think he wants to remove form from the page but wants to have command button Jul 22, 2016 at 16:37
  • 1
    No...read both questions. It's about loops.
    – Adrian Larson
    Jul 22, 2016 at 16:37
  • 1
    @AdrianLarson yes you are correct, kind of duplicate questions Jul 22, 2016 at 16:40

2 Answers 2


If your question is how to use the <apex:commandButton> tag in a loop without including multiple <apex:form> tags, simply move the <apex:form> tag outside the loop.

Not So Good

<apex:repeat ...>
    <apex:form><apex:commandButton ... /></apex:form>


    <apex:repeat ...>
        <apex:commandButton ... />

As per Salesforce standard documentation,

An <apex:commandButton>  component must always be a child of an <apex:form>component.

Other option to call server side action is using apex:actionFunction on button click. But action function also requires apex form.

So you cannot remove apex form from the page if you want to do server side action.

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