2

I have a module and params are being saved through the config form. I want to add some additional params programmatically e.g. a token?

Is this possible?

Thank you.

2

Yes you can save the params of the module programmatically by taking the instance of the extension table

1: JTable update

$table = JTable::getInstance('extension');
$table->load($moduleId);
$table->bind(array('params' => $modparams));

Where $modparams is the params of updated params of the module in JSON format.

But the better way to save a value in params of a module I will suggest you create a form field type and use it in your XML form like

2: Form field type.

<field name="token" type="mytoken"/>

Then in the field file return a hidden field that would be created in place of the XML entry as:

return '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'" />';

When you create your token set it to value of this field and Joomla will save this value in params. for help on Form field type : https://docs.joomla.org/Creating_a_custom_form_field_type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.