Form suitable for volume input

peterk900

Member
The save button on a form clears all the field values, apply retains them all. How can I specify certain fields to repeat and others to be cleared on save ?

Also is there any way to remove the pop-up box saying the record is saved - the operator noting that if a certain field is cleared then the record is saved and they can proceed to enter the next item ? Thanks.
 
I have solved the issue over stopping the record saved pop-up with the Suppress Messages option under Form -> FormProcessing. Very nice !

And I suspect the answer to specifying which fields should be retained when a record is saved involves the use of code with the php Form Plugin. Although I haven't found an example of this my guess is that it boils down to grabbing the fields you want to carry forward before the record is saved...

$field100 = $formModel->getElementData('mytable___field100', true);

and then updating these fields before the form is displayed....

$formModel->data['mytable___field100']= $field100;

Please let me know if there is an easier way.
 
That wouldn't work, because we do an implicit redirect between submitting and reloading. So it's a new page load, and any state has been lost.

You'd probably need to do it with session data. So in a submit plugin, onAfterProcess ...

Code:
$session = JFactory::getSession();
$session->set('some.unique.key.field100', $formModel->getElementData('mytable___field100', true);

... and then in the default for that element, set to eval ...

Code:
$session = JFactory::getSession();
$field100 = $session->get('some.unique.key.field100', '');
$session->clear('some.unique.key.field100');
return $field100;

-- hugh
 
Thanks hugh for the corrected approach and the code samples. I'll give this a go and post back - success or otherwise !

PS I can't find the Submit plugin you refer to in the Downloads section - am I being blind or is it called something else ?
 
Last edited:
It's the PHP plugin.

Within the plugin settings, you then select which hook to run it on, like onBeforeProcess on onAfterProcess, etc. I'd suggest onAfterProcess which gets fired once the form has been validated and written out to the database.

The only slight gotcha with onAfterProcess is that we have stripped the tablename___ prefix off of entries in the $formModel->formData array, so if you access that array directly, you need to use short element names rather than full names. But, I think the $formModel->getElementData() method will compensate for that. But if it doesn't work with full name, just use the short name.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top