pogij Posted December 8, 2011 Share Posted December 8, 2011 Hi. I'm writing web application using PEAR Quickform and I came across this problem: I have a quickform class which looks like something this: class enaana extends HTML_QuckForm { function enaena($x, $y) { parent::HTML_QuickForm('', 'POST', ''); $this->addElement('hidden', 'iks', $x); $this->addElement('hidden', 'ipsilon', $y); $this->addElement('submit', 'submit', 'submit'); $this->display(); } } And I use this class several times in one page like this: ... foreach ($trol as $t2) { ... new enaena($t2->getIks(), $t2->getIpsilon()); ... } ... When I load the page the HTML form looks normal like this: ... <form ...> <div> <input type='hidden' name='iks' value='1'> <input type='hidden' name='ipsilon' value='a'> <input type='submit' name='submit' value='submit'> </div> </form> ... <form ...> <div> <input type='hidden' name='iks' value='2'> <input type='hidden' name='ipsilon' value='b'> <input type='submit' name='submit' value='submit'> </div> </form> ... <form ...> <div> <input type='hidden' name='iks' value='3'> <input type='hidden' name='ipsilon' value='c'> <input type='submit' name='submit' value='submit'> </div> </form> ... But when I click one of the submit buttons for example second submit, the reloaded HTML page will look like this: ... <form ...> <div> <input type='hidden' name='iks' value='2'> <input type='hidden' name='ipsilon' value='b'> <input type='submit' name='submit' value='submit'> </div> </form> ... <form ...> <div> <input type='hidden' name='iks' value='2'> <input type='hidden' name='ipsilon' value='b'> <input type='submit' name='submit' value='submit'> </div> </form> ... <form ...> <div> <input type='hidden' name='iks' value='2'> <input type='hidden' name='ipsilon' value='b'> <input type='submit' name='submit' value='submit'> </div> </form> ... So all components values of all forms are replaced with the values from a form which was submitted. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/ Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 Because they all have the same name. Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/#findComment-1295688 Share on other sites More sharing options...
pogij Posted December 8, 2011 Author Share Posted December 8, 2011 OK. But if instead of quickform i just write HTML code this does not happen: <form ...> <input type='hidden' name='iks' ...> <input type='hidden' name='ipsilon' ...> </form> ... <form ...> <input type='hidden' name='iks' ...> <input type='hidden' name='ipsilon' ...> </form> ... <form ...> <input type='hidden' name='iks' ...> <input type='hidden' name='ipsilon' ...> </form> Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/#findComment-1295695 Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 That's because (I'm assuming) quickform automatically loads the values back into the form when you press submit. And since they all have the same names, they all get the same value. Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/#findComment-1295700 Share on other sites More sharing options...
pogij Posted December 8, 2011 Author Share Posted December 8, 2011 And there is probably no way telling quickform not to do this. Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/#findComment-1295707 Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 I don't know because I'm not familiar with it. However you can easily solve this by giving each form field a unique name. So like iks1, iks2, iks3 ... etc. Quote Link to comment https://forums.phpfreaks.com/topic/252737-pear-quickform/#findComment-1295716 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.