First of all: do you consider sending two forms to two different actions? Thus, you can process each form separately in each action. This should be the "best price" if you are using the Zend MVC component.
Another option is to check the value of the submit button that will be included in the request, for example
<input type="submit" name="save" value="form1" /> // in PHP: // $_POST["save"] will contain "form1" <input type="submit" name="save" value="form2" /> // in PHP: // $_POST["save"] will contain "form2"
Be careful, as the value symbol will be displayed as a button label.
So maybe you want to distingush the form using different submit button names:
<input type="submit" name="save-form1" value="Submit" /> // in PHP: // $_POST["save-form1"] will contain "Submit" <input type="submit" name="save-form2" value="Submit" /> // in PHP: // $_POST["save-form2"] will contain "Submit"
EDIT:
During the comment dialog between OP and me, the following seems to be a possible solution:
class My_Form_Base extends Zend_Form { private static $_instanceCounter = 0; public function __construct($options = null) { parent:: __construct($options); self::$_instanceCounter++; $this->addElement('hidden', 'form-id', sprintf('form-%s-instance-%d', $this->_getFormType(), self::$_instanceCounter); } protected _getFormType() { return get_class($this); } } class My_Form_Type1 extends My_Form_Base { public function init() {
source share