You need to sign in to do that
Don't have an account?
Sviatlana Andryianchyk
Form inputs are not passed within repeatable forms
Hi,
I am trying to pass variable value from visualforce page to my custom controller. But it is constantly null.
This is my page:
I am trying to pass variable value from visualforce page to my custom controller. But it is constantly null.
This is my page:
<apex:page id="productCatalog" controller="ItemController">
<table class="table" id="block"> <apex:repeat value="{! items[key]}" var="item"> <tr> <td class="col-md-2"></td><apex:outputText value="{! item.Name}"/> <td class="col-md-2"> <apex:form > <apex:pageblock > <apex:inputText value="{!myinput}"/> <apex:commandButton value="Submit" reRender="outputID" action="{!MyMethode}"/> </apex:pageblock> </apex:form> </td> </tr> </apex:repeat> </table>
</apex:page>And tis is my controller:
public with sharing class ItemController { public string myInput{get;set;} public void MyMethode(){ System.debug(myInput); }When I place form element out of the repeat block, everything works ok. But now the value of myInput is constantly null. Thank yoy in advance!
You are using <apex:form> <apex:inputText value="{!myinput}"/> in <apex:repeat> tag.
At the time of submit, controller does not know which instance of 'myinput' and from which Form you are referring to. My suggestion is to take the 'myinput' variable out of repeat tag. You can check with below code the value is coming perfect fine - If you really want to use <apex:form > <apex:inputText value="{!myinput}"/> in <apex:repeat> tag. We can write something like below using apexFunction, HTML input, JS Please follow above code which might help.
Mark it as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering similar issue.
Thanks,
Nagendra.