Wpff_Tokens::create_token( $form_id,  $field,  $trigger_meta,  $field_group_name = '' )


Parameters Parameters

$form_id

(Required)

$field

(Required)

$trigger_meta

(Required)

$field_group_name

(Optional)

Default value: ''


Top ↑

Return Return

(array)


Source Source

File: src/integrations/wp-fluent-forms/tokens/wpff-tokens.php

	public function create_token( $form_id, $field, $trigger_meta, $field_group_name = '' ) {

		$field_label = '';
		if( isset( $field['settings']['label'] ) ) {
			$field_label = $field['settings']['label'];
		} elseif( isset( $field['settings']['admin_field_label'] ) ) {
			$field_label = $field['settings']['admin_field_label'];
		}

		$field_name  = $field['attributes']['name'];

		if ( isset( $field['attributes']['type'] ) ) {
			$field_type = $field['attributes']['type'];
		} else {
			$field_type = $field['element'];
		}


		switch ( $field_type ) {
			case 'number':
				$type = 'int';
				break;
			default:
				$type = 'text';
				break;
		}

		if ( empty( $field_group_name ) ) {
			$token_id = "$form_id|$field_name";
		} else {
			$token_id = "$form_id|$field_group_name|$field_name";
		}

		return [
			'tokenId'         => $token_id,
			'tokenName'       => $field_label,
			'tokenType'       => $type,
			'tokenIdentifier' => $trigger_meta,
		];

	}