I am trying to create my own settings form (EE5) using the documentation, but when i am using the function settings_form() & save_settings() and calling the "return ee('View')->make('my_extension:index')->render($vars);" it will not save. It displays correctly and submits the form but doesn't save. When I run the settings() function it works fine, but I need to create some custom areas. Anyone experiencing similar issues with it not saving.
save_settings() method doesn't do anything with your settings data simply by existing - you need to process the submission yourself. From the docs:
Use it to process the data sent and put it into the
exp_extensionsdatabase table. Remember that the data put into the database is a serialized array, so handle it appropriately.
The easiest way to do this is using the existing Extension model, which abstracts a lot of that work for you:
$model = ee('Model')->get('Extension') ->filter('class', ucfirst(get_class($this))) ->first(); $my_settings = array( 'foo' => ee('Request')->post('foo'), 'bar' => ee('Request')->post('bar') ); $model->settings = $my_settings; $model->save();
settings property of the
Extension model is set to be serialized data, you only have to assign an array to it - the serialization will happen in the model.)