Lasso Soft Inc. > Home

[join_params]

Linkjoin_params
AuthorDominique Guardiola Falco
CategoryArray
Version8.5.x
LicensePublic Domain
Posted08 Apr 2008
Updated08 Apr 2008
More by this author...

Description

This ctag merges the GET and POST parameters of a submitted form, and re-arrange the parameters to group in one value the repeated items coming from input checkboxes or multiple selects.

It returns an array ready for include in your inline, given the name of the parameters match your database fields names.
You can filter the arguments from the POST/GET submission using an array of unwanted names (name=value pairs which don't match any field in your db, or false fields used in your form).
The default separator is a comma (',') but you can choose another.

Sample Usage

//full client_params, repeating fields joined :
join_params;


//for this form POST :     
    * pair: (choice)=(20058)
    * pair: (choice)=(103)
    * pair: (choice)=(8887)
    * pair: (update)=(news)
    * pair: (id)=(007)
    * pair: (cookie)=(yes)

join_params(-unwanted=array('cookie','update'), -sep='|');

//will return :

array: (pair: (id)=(007)),(pair: (choice)=(20058|103|8887))

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'params',	
	-optional='unwanted',
	-optional='sep',
	-namespace='join_',
	-priority='replace',
	-description='Join multiple POST or GET arguments with the same name under the same value, using a custom separator.'
	);
	
	local('merged_params') = array;
	#merged_params->merge(client_getparams);
	#merged_params->merge(client_postparams);

	!local_defined('sep') ? local('sep')= string(',');
	!local_defined('unwanted') ? local('unwanted')= null;
	
	local('fields_map') = map;
	local('fields_array') = array;
	
	iterate: #merged_params, local('tmp');
		if: #unwanted !>> #tmp->first;	
			if: #fields_map !>> #tmp->first;	
				#fields_map->(insert: #tmp->first=#tmp->second);		
			else;		
				#fields_map->(insert:#tmp->first=(#fields_map->(find:#tmp->first))+#sep+#tmp->second);		
			/if;	
		/if;	
	/iterate;
		
	iterate:#fields_map, local('tmp');
		#fields_array->(insert:#tmp->first=#tmp->second);
	/iterate;
	
	return(#fields_array);

/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft