Jump to content

Widget settings. Validation


newbie LAC

Recommended Posts

Hello,

Widget settings validation doesn't work.

Code 

	public function configuration( &$form=null )
	{
		if ($form === null)
		{
			$form = new \IPS\Helpers\Form;
		}

		$form->add( new \IPS\Helpers\Form\Text(
			'custom_validate',
			isset($this->configuration['custom_validate']) ? $this->configuration['custom_validate'] : null,
			false,
			array(),
			function($val)
			{
				if ($val == 'bad')
				{
					throw new \InvalidArgumentException('form_bad_value');
				}
			}
		) );
		
		$form->add( new \IPS\Helpers\Form\Text(
			'required_field',
			isset($this->configuration['required_field']) ? $this->configuration['required_field'] : null,
			true,
			array()
		) );
		
		return $form;
 	}

widget.thumb.gif.5314036f0cd4531a4c84ba10cbf4fc8d.gif

I changed in applications/core/modules/front/system/widgets.php

from

						\IPS\Output::i()->sendOutput( $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget ) );

to 

						\IPS\Output::i()->output = $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget );

Result

widget2.gif.347e578095730a402cb121e9fa0fdd9d.gif

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...