I have the following code.
$form = $this->init_module('Libs/QuickForm');
$form->addElement('header', 'title', __('Xero Connect'));
$form->addElement('text','consumer_key',__('Consumer Key'),array('style'=>'width:250px'));
$form->addElement('text','secret_key',__('Consumer Secret'), array('style'=>'width:250px'));
$form->addElement('submit', 'save_btn', __('Save')); //, $form->get_submit_form_href());
$form->addElement('header', 'subtitle1', __('X509 Certificate'));
$form->addElement('textarea', 'key_txt', null, array('readonly'=>true, 'style'=>'margin-top:5px;height:100px;width:250px'));
$msg = '<div style="width:250px">Copy and paste this certificate to your Xero Dashboard to generate your consumer and secret keys.</div>';
$form->addElement('static', 'static_text_1', '', $msg);
$form->addElement('button', 'cert_btn', __('Generate New Certificate'), $form->get_submit_form_href());
$form->addElement('header', 'subtitle2', __('Synchronise with Xero'));
$form->addElement('submit', 'sync_btn', __('Synchronise Now')); //, $form->get_submit_form_href());
if ($form->validate()) {
$values = $form->exportValues();
var_dump($values);
}
However when the Synchronise Now button is clicked I get the following output:
array(5) { ["submited"]=> string(1) "1" ["consumer_key"]=> string(30) "AENYJU0R......GHYJBKH" ["secret_key"]=> string(30) "V25VTLF6N........HHRTRVNUTD" ["save_btn"]=> string(4) "Save" ["key_txt"]=> string(924) "-----BEGIN CERTIFICATE----- MIICfjCCAeegAwIBAgIJAJlZaop+Wa8lMA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV BAYTAk5aMRAwDgYDVQQIDAdIYXVyYWtpMQ4wDAYDVQQHDAVXYWloaTELMAkGA1UE CgwCUHIxGjAYBgNVBAMMEXd3dy5wcmludGVjLmNvLm56MB4XDTE1MDcwNTAyNTMz N1oXDTE2MDcwNDAyNTMzN1owWDELMAkGA1UEBhMCTloxEDAOBgNVBAgMB0hhdXJh a2kxDjAMBgNVBAcMBVdhaWhpMQswCQYDVQQKDAJQcjEaMBgGA1UEAwwRd3d3LnBy aW50ZWMuY28ubnowgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOWVqsdrvkYO v4mCNQur2FOwvUOPSa20qA24I3FR8R/aaj2n0i5yrm/utScGhmlXv59Cb4dYNQZC qwo3U0I2TkQtfRIIHkM9st8hRnj9xF9QL29CdT8il4AUckAdT0TxNaMOIVtTYeIw vl2hOFp+/PX0nOy1hNBNRyowiL/7mkcFAgMBAAGjUDBOMB0GA1UdDgQWBBRjSVez iQlZNGmTPHV53+FDhW744jAfBgNVHSMEGDAWgBRjSVeziQlZNGmTPHV53+FDhW74 4jAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GBAK45t2Som4Vwm+dFhEkY 6ksADm3xqWtQ0O5qu0cadPo3pXUElTpPZlX4cBQ1lWuL6LM5+eKb/EOgOTIBNrT1 SzEgVe9/ZdPtn5RqW5yqzchqmjsQg1PcoAL9wvJVai9g8P1eRGqvX5A+P1e2I3IN i3qvkm2gtH2zfWtVXAUSdLui -----END CERTIFICATE----- " }
Note the "save_btn" array key while expecting "sync_btn". I had a look at Chrome Inspector and it does render as <input name="sync_btn" value="Synchronise Now" type="submit"> in the browser.
Is there something strange happening with the form javascript onsubmit handler? How do I get the second submit button to behave a bit more like a second form?
--- Edit ----
Ok, I kind of figured it out. I declared a second form in code:
$form = $this->init_module('Libs/QuickForm');
$form->addElement('header', 'title', __('Xero Connect Keys'));
$form->addElement('text','consumer_key',__('Consumer Key'),array('style'=>'width:250px'));
$form->addElement('text','secret_key',__('Consumer Secret'), array('style'=>'width:250px'));
$form->addElement('submit', 'save_btn', __('Save')); //, $form->get_submit_form_href());
$form->addElement('header', 'subtitle1', __('X509 Certificate'));
$form->addElement('textarea', 'key_txt', null, array('readonly'=>true, 'style'=>'margin-top:5px;height:100px;width:250px'));
$msg = '<div style="width:250px">Copy and paste this certificate to your Xero Dashboard to generate your consumer and secret keys.</div>';
$form->addElement('static', 'static_text_1', '', $msg);
$form->addElement('button', 'cert_btn', __('Generate New Certificate'), $form->get_submit_form_href());
$sync_form = $this->init_module('Libs/QuickForm');
$sync_form->addElement('header', 'subtitle2', __('Synchronise with Xero'));
$sync_form->addElement('submit', 'sync_btn', __('Synchronise Now')); //, $form->get_submit_form_href());
$form->display();
$sync_form->display();
However, it messes a bit with the layout.
Any ideas on how to fix so that "Synchronise with Xero" header displays full width?
Regards
Glenn