Hi
I have a form in which a user will be able to apporve the data. I created an element 'Approved' to monitor among records which are approved and which are not.
I'm trying to create a button beside the save button which changes and saves the value of the 'Approved' element to 'Yes' when clicked.
I've checked few previous posts to guide me through and I've managed to create the button though a form JS and PHP as discussed in
http://fabrikar.com/forums/index.php?threads/add-custom-button-next-to-submit.46758/.
In the post above I changed the form event from 'fabrik.form.submit' to 'fabrik.form.submit.start' to get it working and the new button appears but the change is not saved in the db. I can see the '.update('Yes')' method works if I put a line of code to interrupt the operation. It just seems the change is made after submit.
Hear is my form_X.js
and the fabrik-custom-button.php
What am I missing?, Any help is greatly appreciated.
I have a form in which a user will be able to apporve the data. I created an element 'Approved' to monitor among records which are approved and which are not.
I'm trying to create a button beside the save button which changes and saves the value of the 'Approved' element to 'Yes' when clicked.
I've checked few previous posts to guide me through and I've managed to create the button though a form JS and PHP as discussed in
http://fabrikar.com/forums/index.php?threads/add-custom-button-next-to-submit.46758/.
In the post above I changed the form event from 'fabrik.form.submit' to 'fabrik.form.submit.start' to get it working and the new button appears but the change is not saved in the db. I can see the '.update('Yes')' method works if I put a line of code to interrupt the operation. It just seems the change is made after submit.
Hear is my form_X.js
JavaScript:
Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
if (button.name === 'approve') {
form.formElements.get('mytablename___approved').update('Yes');
}
})
and the fabrik-custom-button.php
PHP:
<?php
defined('JPATH_BASE') or die;
$d = $displayData;
?>
<?php
if ($d->formModel->getId() == xx /*xx is the form number*/) {
?>
<button type="submit" class="btn btn-primary button save" name="approve">approve</button>
<?php
}
?>
What am I missing?, Any help is greatly appreciated.