Hf_Tokens::hf_possible_tokens( array $tokens = array(), array $args = array() )
Prepare tokens.
Contents
Parameters Parameters
- $tokens
-
(Optional) .
Default value: array()
- $args
-
(Optional) .
Default value: array()
Return Return
(array)
Source Source
File: src/integrations/happyforms/tokens/hf-tokens.php
public function hf_possible_tokens( $tokens = array(), $args = array() ) { $form_id = $args['value']; $trigger_integration = $args['integration']; $trigger_meta = $args['meta']; if ( ! empty( $form_id ) && 0 !== $form_id && is_numeric( $form_id ) ) { $form_controller = happyforms_get_form_controller(); $form = $form_controller->get( $form_id ); if ( $form ) { $fields = array(); $meta = $form['parts']; if ( is_array( $meta ) && ! empty( $meta ) ) { foreach ( $meta as $field ) { $input_id = $field['id']; $input_title = $field['label'] . ( $field['type'] !== '' ? ' (' . $field['type'] . ') ' : '' ); $token_id = "$form_id|$input_id"; $fields[] = [ 'tokenId' => $token_id, 'tokenName' => $input_title, 'tokenType' => $field['type'], 'tokenIdentifier' => $trigger_meta, ]; } } $tokens = array_merge( $tokens, $fields ); } } return $tokens; }
Expand full source code Collapse full source code View on Github