Jump to content

Save Application Settings


Recommended Posts

I have created an application, and everything works fine, but after clicking the save button, I don't see the 'Saved' flash message.

my codes:
 

protected function manage()
	{
		$form = new \IPS\Helpers\Form;
		$form->add( new \IPS\Helpers\Form\Number( 'createtopic_setting_left', \IPS\Settings::i()->createtopic_setting_left ) );

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

		\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menutab__test');
		\IPS\Output::i()->output = $form;
	}

whats wrong with that?

 

thanks in advance

Link to comment
Share on other sites


  • Management

For the message to appear you need to add a redirect inside the IF check after the settings are saved.

\IPS\Output::i()->redirect( YOUR_PAGE_REDIRECT_URL, 'saved' );

 

Here's the full code:

	protected function manage()
	{
		$form = new \IPS\Helpers\Form;
		$form->add( new \IPS\Helpers\Form\Number( 'createtopic_setting_left', \IPS\Settings::i()->createtopic_setting_left ) );

		if ($values = $form->values(true))
		{
			$form->saveAsSettings($values);
			
			# Redirect showing a message
			\IPS\Output::i()->redirect( YOUR_PAGE_REDIRECT_URL, 'saved' );
		}

		\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menutab__test');
		\IPS\Output::i()->output = $form;
	}

Replace the redirect URL, and you can change the language string used for the message in the second parameter. The example above uses the generic Saved language string.

Board Rules - Available Products - Need a Custom Work?

 

< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.