Jump to content

How can I add a setting to my plugin


rzda

Recommended Posts

Hello, I'm trying to create a plugin and I want to add some settings to it.

a9756981289b437194f1eee1a2375d0a.png
I want to add those 2 settings to work something like this

b24a26d99bc830ec3d09ef6ad04c023a.png
But I don't know what code I should add to "Content" because it's seems the {lang= it doesn't work.

Link to comment
Share on other sites

Ok buddy

This is what I have in settings.php in FTP /plugins/name/

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

And this in /plugins/name/dev/html

<ips:template parameters="" />

<i style='color: {setting="color_icon_aws"}' class='fa fa-{setting="shape_icon_aws"}'></i>

Also this is what I have in settings of the plugin

6efcf47b17cb63d3e75c39e15427291e.png
https://gyazo.com/6efcf47b17cb63d3e75c39e15427291e

Link to comment
Share on other sites

4 hours ago, Nathan Explosion said:

Nothing else? Show all the code you have in the file.

Nothing else.

This is in settings.php

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) ); $form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) ); $form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

this is the plugin

<ips:template parameters="" />

<i style='color: {setting="color_icon_aws"}' class='fa fa-{setting="shape_icon_aws"}'></i>

6efcf47b17cb63d3e75c39e15427291e.png&key

those are the settings.

AS I SAID, THEY ARE NOT SAVING.

Like on groups i put 4 and press save, the message "Saved." appears but when i click edit again the 4 is not there.

 

Link to comment
Share on other sites

20 minutes ago, Sharpyku said:

Nothing else

That's why it isn't saving. You need to have:

$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

if ( $values = $form->values() )
{
	$form->saveAsSettings();
	return TRUE;
}

return $form;

 

Link to comment
Share on other sites

5 minutes ago, Sharpyku said:

AS I SAID, THEY ARE NOT SAVING.

I KNOW!!!

Where is the saving section of the settings.php? It would explain loads y'see....it's the bit at the end of the settings.rename.php that your plugin has when you create it:

//<?php

$form->add( new \IPS\Helpers\Form\Text( 'plugin_example_setting', \IPS\Settings::i()->plugin_example_setting ) );

if ( $values = $form->values() )
{
	$form->saveAsSettings();
	return TRUE;
}

return $form;

image.thumb.png.4a63f8119dd90e244f41ed39e7c006b9.png

 

Link to comment
Share on other sites

8 minutes ago, Adriano Faria said:

That's why it isn't saving. You need to have:


$form->add( new \IPS\Helpers\Form\Text( 'shape_icon_aws', \IPS\Settings::i()->shape_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'shape_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'color_icon_aws', \IPS\Settings::i()->color_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'color_icon_aws' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'groups_icon_aws', \IPS\Settings::i()->groups_icon_aws, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'groups_icon_aws' ) ) );

if ( $values = $form->values() )
{
	$form->saveAsSettings();
	return TRUE;
}

 

Lol thanks man im such a noob.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...