New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The new subform field returns NULL instead of the default value #11318
Comments
That's the expected behavior, not a bug. Any parameter/property is NULL if not defined in a Registry object. So, use: Or use |
You're almost right. Take a look here: https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/installer/installer.php#L1555 - the installer parses the default values from plugin.xml and stores them in the database, so the default value should always be defined in the registry object. However, it doesn't handle the subform field properly, i.e. by parsing the formsource file and storing its default values. |
nope, same is true for simple text field <field name="property_sets" type="text" default="ueueue"/> $value = $this->params->get('property_sets');
you can have default value in next way: $sets = $this->params->get('property_sets', array('foo' => 'bar') /*... default value ...*/); |
or wait, I did not seen that installer.php#L1555 parse something, <field name="property_sets" type="subform" formsource="plugins/system/plugin/propset.xml"
default='[{field: "value"}, {field: "value2"} ... ]' .... but I think installer.php#L1555 will parse it as simple string instead of json 😄 well, just use $sets = $this->params->get('property_sets', array('foo' => 'bar')); |
Closed as expected behaviour This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11318. |
Sure, putting escaped JSON in an XML attribute is such a good idea, next thing I need a custom build system to parse any referenced subform when packing in a simple plugin, and hardcode it inside a PHP script or an XML attribute. How about we fix the installer to properly handle nested fields instead of hacking our way around? |
Oh and @brianteeman, maybe check GitHub once in a while and you'll notice @Fedik overlooked the parsing in installer.php, so reopen maybe? |
it not really haking, it how thing works
well, I do not see any hardkoding in use Registry API to have the default value in your code $params->get('key', $default); it is easy |
And I'm supposed to set the While I understand it can work by entering the same config multiple times, it's not something to be encouraged as it leads to inconsistency and hard-to-maintain code. |
Steps to reproduce the issue
In plugin.xml add something like
Then within the plugin.php call
Expected result
$sets
contains one set with default values from propset.xml.Actual result
$sets
is NULL when plugin is installed. The user has to open and save plugin config for the default values to load.System information (as much as possible)
Joomla! 3.6.0
The text was updated successfully, but these errors were encountered: