private function convertMultipleColumns(& $values) {
		// regular fields
		foreach ($this->fields as $k => $v) {
			if (!empty($v['options']['multiple_column'])) {
				if (!empty($values[$k])) {
					pk($v['options']['multiple_column'], $values[$k]);
					$values[$k] = array_keys($values[$k]);
				}
			}
		}
		// details
		foreach ($this->detail_fields as $k => $v) {
			if (empty($values[$k]) || !is_array($values[$k])) continue;
			if (!empty($v['options']['details_convert_multiple_columns'])) {
				$widget_model = \Factory::model($k, true);
				$widget_model->convertMultipleColumns($this, $values[$k]);
			} else if (!empty($values[$k])) { // convert fields
				// 1 to 1
				if (!empty($v['options']['details_11'])) {
					$details = [$values[$k]];
				} else { // 1 to M
					$details = $values[$k];
				}
				foreach ($details as $k5 => $v5) {
					if (!empty($v['options']['details_11'])) {
						$values_key = [$k];
					} else {
						$values_key = [$k, $k5];
					}
					foreach ($v['elements'] as $k2 => $v2) {
						if (!empty($v2['options']['multiple_column'])) {
							if (!empty($v5[$k2])) {
								$temp = $v5[$k2];
								pk($v2['options']['multiple_column'], $temp);
								array_key_set($values, array_merge($values_key, [$k2]), array_keys($temp));
							}
						}
					}
				}
			}
			// subdetails
			if (!empty($v['subdetails'])) {
				foreach ($values[$k] as $k11 => $v11) {
					foreach ($v['subdetails'] as $k0 => $v0) {
						if (!empty($v0['options']['details_convert_multiple_columns'])) {
							$widget_model = \Factory::model($k0, true);
							$widget_model->convertMultipleColumns($this, $values[$k][$k11][$k0]);
						}
					}
				}
			}
		}
	}
private function convertMultipleColumns(& $values) {
		// regular fields
		foreach ($this->fields as $k => $v) {
			if (!empty($v['options']['multiple_column'])) {
				if (!empty($values[$k])) {
					pk($v['options']['multiple_column'], $values[$k]);
					$values[$k] = array_keys($values[$k]);
				}
			}
		}
		// details
		foreach ($this->detail_fields as $k => $v) {
			if (empty($values[$k]) || !is_array($values[$k])) continue;
			if (!empty($v['options']['details_convert_multiple_columns'])) {
				$widget_model = \Factory::model($k, true);
				$widget_model->convertMultipleColumns($this, $values[$k]);
			} else if (!empty($values[$k])) { // convert fields
				// 1 to 1
				if (!empty($v['options']['details_11'])) {
					$details = [$values[$k]];
				} else { // 1 to M
					$details = $values[$k];
				}
				foreach ($details as $k5 => $v5) {
					if (!empty($v['options']['details_11'])) {
						$values_key = [$k];
					} else {
						$values_key = [$k, $k5];
					}
					foreach ($v['elements'] as $k2 => $v2) {
						if (!empty($v2['options']['multiple_column'])) {
							if (!empty($v5[$k2])) {
								$temp = $v5[$k2];
								pk($v2['options']['multiple_column'], $temp);
								array_key_set($values, array_merge($values_key, [$k2]), array_keys($temp));
							}
						}
					}
				}
			}
			// subdetails
			if (!empty($v['subdetails'])) {
				foreach ($values[$k] as $k11 => $v11) {
					foreach ($v['subdetails'] as $k0 => $v0) {
						if (!empty($v0['options']['details_convert_multiple_columns'])) {
							$widget_model = \Factory::model($k0, true);
							$widget_model->convertMultipleColumns($this, $values[$k][$k11][$k0]);
						}
					}
				}
			}
		}
	}
private function convertMultipleColumns ( & $ values ) { // regular fields foreach ( $ this -> fields as $ k => $ v ) { if ( ! empty ( $ v [ 'options' ] [ 'multiple_column' ] ) ) { if ( ! empty ( $ values [ $ k ] ) ) { pk ( $ v [ 'options' ] [ 'multiple_column' ] , $ values [ $ k ] ) ; $ values [ $ k ] = array_keys ( $ values [ $ k ] ) ; } } } // details foreach ( $ this -> detail_fields as $ k => $ v ) { if ( empty ( $ values [ $ k ] ) || ! is_array ( $ values [ $ k ] ) ) continue ; if ( ! empty ( $ v [ 'options' ] [ 'details_convert_multiple_columns' ] ) ) { $ widget_model = \ Factory :: model ( $ k , true ) ; $ widget_model -> convertMultipleColumns ( $ this , $ values [ $ k ] ) ; } else if ( ! empty ( $ values [ $ k ] ) ) { // convert fields // 1 to 1 if ( ! empty ( $ v [ 'options' ] [ 'details_11' ] ) ) { $ details = [ $ values [ $ k ] ] ; } else { // 1 to M $ details = $ values [ $ k ] ; } foreach ( $ details as $ k5 => $ v5 ) { if ( ! empty ( $ v [ 'options' ] [ 'details_11' ] ) ) { $ values_key = [ $ k ] ; } else { $ values_key = [ $ k , $ k5 ] ; } foreach ( $ v [ 'elements' ] as $ k2 => $ v2 ) { if ( ! empty ( $ v2 [ 'options' ] [ 'multiple_column' ] ) ) { if ( ! empty ( $ v5 [ $ k2 ] ) ) { $ temp = $ v5 [ $ k2 ] ; pk ( $ v2 [ 'options' ] [ 'multiple_column' ] , $ temp ) ; array_key_set ( $ values , array_merge ( $ values_key , [ $ k2 ] ) , array_keys ( $ temp ) ) ; } } } } } // subdetails if ( ! empty ( $ v [ 'subdetails' ] ) ) { foreach ( $ values [ $ k ] as $ k11 => $ v11 ) { foreach ( $ v [ 'subdetails' ] as $ k0 => $ v0 ) { if ( ! empty ( $ v0 [ 'options' ] [ 'details_convert_multiple_columns' ] ) ) { $ widget_model = \ Factory :: model ( $ k0 , true ) ; $ widget_model -> convertMultipleColumns ( $ this , $ values [ $ k ] [ $ k11 ] [ $ k0 ] ) ; } } } } } }
Convert multiple columns
Convert multiple columns