[TYPO3-core] RFC: Bug 5098: IRRE - foreign_unique without foreign_selector doesn't work

Ingmar Schlecht ingmar at typo3.org
Sun Mar 4 00:05:35 CET 2007


Hi Olly,

I don't have the time to test the patch right now, but as we're very
close to the final release, I would like to ask you to commit your patch
if you're 100% sure it does what it's supposed to and hasn't got any
sideffects.

cheers
Ingmar

Oliver Hader schrieb:
> This is a SVN patch request.
> 
> Problem:
> If in TCA on the parent side a field of type "inline" is defined to be
> unique ("foreign_unique") and no selector is used ("foreign_selector")
> this will produce a JavaScript error. The reason is a wrong value
> delivered by JSON concerning uniqueness/selector.
> 
> Solution:
> Correct the selector value to be delivered via JSON.
> 
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=5098
> 
> Branch: Trunk
> 
> 
> olly
> 
> 
> ------------------------------------------------------------------------
> 
> Index: t3lib/class.t3lib_tceforms_inline.php
> ===================================================================
> --- t3lib/class.t3lib_tceforms_inline.php	(Revision 2163)
> +++ t3lib/class.t3lib_tceforms_inline.php	(Arbeitskopie)
> @@ -193,7 +193,7 @@
>  
>  			// if relations are required to be unique, get the uids that have already been used on the foreign side of the relation
>  		if ($config['foreign_unique']) {
> -				// If unique *and* selector, the should both be the same - get config:
> +				// If uniqueness *and* selector are set, they should point to the same field - so, get the configuration of one:
>  			$selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_unique']);
>  				// Get the used unique ids:
>  			$uniqueIds = $this->getUniqueIds($recordList, $config, $selConfig['type']=='groupdb');
> @@ -206,7 +206,7 @@
>  				'table' => $config['foreign_table'],
>  				'elTable' => $selConfig['table'], // element/record table (one step down in hierarchy)
>  				'field' => $config['foreign_unique'],
> -				'selector' => $selConfig['PA'] && $selConfig['type'] ? $selConfig['type'] : false,
> +				'selector' => $selConfig['selector'],
>  				'possible' => $this->getPossibleRecordsFlat($possibleRecords),
>  			);
>  		}
> @@ -1564,6 +1564,7 @@
>  		$PA = false;
>  		$type = false;
>  		$table = false;
> +		$selector = false;
>  		
>  		if ($field) {
>  			$PA = array();
> @@ -1575,12 +1576,17 @@
>  			$type = $this->getPossibleRecordsSelectorType($config);
>  				// Return table on this level:
>  			$table = $type == 'select' ? $config['foreign_table'] : $config['allowed'];
> +				// Return type of the selector if foreign_selector is defined and points to the same field as in $field:
> +			if ($foreign_selector && $foreign_selector == $field && $type) {
> +				$selector = $type;
> +			}
>  		}
>  		
>  		return array(
>  			'PA' => $PA,
>  			'type' => $type,
> -			'table' => $table
> +			'table' => $table,
> +			'selector' => $selector,
>  		);
>  	}
>  	



More information about the TYPO3-team-core mailing list