Jump to content

\IPS\Helpers\Form\Item::html don't follow itemTemplate value


BomAle

Recommended Posts

I am trying to change default itemResult template with my custom template but it seem not work because \IPS\Helpers\Form\Item::html don't follow itemTemplate option.

$template = NULL;
if ( $this->options['itemTemplate'] === NULL )
{
	$template = array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' ), 'itemResult' );
}
/* Are we getting some AJAX stuff? */
if ( isset( \IPS\Request::i()->_itemSelectName ) and \IPS\Request::i()->_itemSelectName === $this->name )
{
	/*.....*/
	foreach( $class::getItemsWithPermission( $where, 'LENGTH(' . $field . ') ASC', array( 0, 20 ), $this->options['permissionCheck'] ) as $item )
	{
		$results[] = array(
			'id'	=> $item->$idField,
			'html'  => call_user_func( $template, $item )
		);
	}
	\IPS\Output::i()->json( $results );
}

There is a future change about IPS developers? or I must use a theme hook inside itemResult and check if item is a instanceof a specific class?

Thanks for support :thumbsup:

Link to comment
Share on other sites

This is a bug I reported myself about a month ago, it should be fixed in 4.2.6 already though.

The fix is to replace this code above:

		$template = NULL;
		if ( $this->options['itemTemplate'] === NULL )
		{
			$template = array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' ), 'itemResult' );
		}

with this one:

		$template = NULL;
		if ( $this->options['itemTemplate'] === NULL )
		{
			$template = array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' ), 'itemResult' );
		}
		else
		{
			$template = $this->options['itemTemplate'];
		}

 

EDIT: as a workaround in my own app I extended the form helper replacing the code with the fixed one until I upgrade to the version that contains the fix.

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