Recent Topics

Request: Form item type: 'hidden'

Started by on Oct 21, 2016 – Contents updated: Oct 30, 2016

Oct 21, 2016 12:31    

in inc/plugins/_plugin.class.php

there are various form item types defined such 'text' or 'checkbox' that can be used in plugins/widgets, please can 'hidden' types also be added?

Oct 21, 2016 13:21

I am not sure if this is a bug or if it simply is not compatible with widget settings, but if one creates a field with 'no_edit' set to true the whole field disappears and isn't stored at all.

I am trying to pass a widget param ($wi_ID) that must not be editable for SkinTag

Oct 21, 2016 15:28

Please make this extra clear with a screenshot of where you need the hidden form and also please explain what you need it for in your use case so we can document the use of the "hidden" type.

Oct 21, 2016 15:48

@fplanque I will try post a better screenshot later: in the meanwhile, here is the situation.

1) I created a plugin (widget type);
2) Installed only once;
3) can be added multiple times in the widgets containers;
4) I need to pass the $wi_id to $params['wi_ID']; this is done when the widget is created and saved through get_widget_param_definitions( $params).
5) The user must NOT be able to change it. In fact they don't even need to see it.
6) it is then used in SkinTag to identify the specific widget.

At the moment, I am using a select list with only the wi_ID as the only option. So the user can't mess it up because if I use 'disabled' => true, or 'no_edit' => true it does not work.

Oct 22, 2016 15:49

1) so the first thing you did. To explicitly says was that this is the widget settings form and not the plugin settings form.

2) Please copy/paste the code where you define these fields. What function is it in the plugin?

3) if the wi-ID is generated by b2evolution, you can get it from b2evolution at any time. So why do you need to pass it through the form? What make sure it impossible for you to get it later if you don't pass it through the form?

4) please show me the code of where you use the wi-ID in the end I the skintag. What do you do with it? Add a DOM ID or a CSS class based on that ID?

Oct 22, 2016 18:37

The widget Settings:


	function get_widget_param_definitions( $params )
	{
		global $wi_ID, $Blog;

		$r = array(

								/*
								*	$wi_ID is not passed through to skin tag so pass it through $params
								*	This should be a normal text type that should actually be hidden
								*	this wi_ID must be included so that we can identify it in SkinTag
								*
								*/
								'wi_ID' => array(
									'label' => T_('Widget ID'),
									'defaultvalue' => $wi_ID,
									//'no_edit'  => true, // Not working
									//'disabled' => true, // Not working
									'type' => 'select',
									'options' => array( $wi_ID => $wi_ID ),
									'note' =>  T_('This is the widget ID, it cannot be changed.'),
								),
						
								
							'File_ID' => array(
								'label' => $this->T_( 'Files Select' ),
								'type' => 'select',
								'multiple' => true,
								'allow_none' => true,
								'options' => $this->file_list(),
								'rows' => 7,
								'defaultvalue' => '',
								'note' => $this->T_( 'Select files to include (ctrl + click)' )
							),
							);
						
						
					
		return $r;	
	}

	function SkinTag( & $params )
	{
		global $wi_ID;
		
		/*	
			$wi_ID is not available here???	
			
			then perhaps get it through the params
			
		*/	
		
		if( ! $wi_ID ) echo 'params WI ID: '.$params['wi_ID']; // displays params WI ID: 122
		
		echo '<br />';
		
		echo 'global WI ID: '.$wi_ID;
		
		echo '<br />';
		
		/*	
			so function is inserted here  ( $wi_ID == 122 ? 'do this' : 'do that' ) ;
			
		*/
		
		echo ( $params['wi_ID'] == 122 ? 'do this' : 'do that' ) ;
		

		/*	
		*	the inserted function get_widget_order(  $wi_ID  ) @returns numeric value
		*	it actually checks if the widget is ordered first (1) and if so then it includes additional message
		*	
		*/
		
		return true;
		
		}

Oct 22, 2016 18:41

@fplanque wrote earlier:

3) if the wi-ID is generated by b2evolution, you can get it from b2evolution at any time...

a beg to differ because 'any' time does not include the function SkinTag( & $params )
it is not included through globals

Oct 23, 2016 04:48

a beg to differ because 'any' time does not include the function SkinTag( & $params )
it is not included through globals

Ok, so what if we make it available there? (which sounds easier to me than supporting hidden fields which feel like a hack here).

Oct 23, 2016 15:07

Thanks, that would solve so the problem perfectly


Form is loading...

multiblog platform – This forum is powered by b2evolution CMS, a complete engine for your website.