function execute($options = array()) { if (!isset($options)) { $options = array(); } $options = array_merge($this->getOptions(), $options); $formEngine = new AMPForm($this->udm->name); //Create the Form $admin = $this->_adminConfig(); $formEngine->addFields($this->_setupUdmFields()); $formEngine->setFieldOrder($this->udm->getFieldOrder()); $formEngine->defineSubmit('btnUdmSubmit', $options['button_label']); $formEngine->Build($admin); //set data Requirements $formEngine->validateEmail(); if (!$admin) { $formEngine->enforceRules(); } //Populate the form //$formEngine->setValues( $this->udm->getStoredValues() ); //$formEngine->setValues( $this->udm->getData() ); $stored_values = $this->udm->getStoredValues(); $stored_data = $this->udm->getData(); $all_values = array_merge($stored_values, $stored_data); $formEngine->setValues($all_values); if ($form_attrs = $this->getRegisteredFieldAttrs()) { foreach ($form_attrs as $field => $field_attrs) { foreach ($field_attrs as $attr) { $formEngine->addFieldAttr($field, $attr); } } } //register results with udm $this->udm->form = $formEngine->form; if ($script = $formEngine->getJavascript()) { $this->_register_javascript($script); } if ($this->udm->submitted) { if (!$formEngine->validate() && !$admin) { $this->udm->formInvalidCallback(); return false; } } $this->_formEngine =& $formEngine; return $formEngine->form; }
function defineSubmit($value, $label = 'Submit') { $result = parent::defineSubmit($value, $label); $this->_submit_value = $value; }