public function getKey(): string
    {
        if ($this->key) {
            return $this->key;
        }

        // If the user has set a custom key.
        if ($this->config->has('key')) {
            $key = Key::validate($this->config->get('key'), 'field');

            $this->key = $key;

            return $key;
        }

        // For fields which doesn't require name attribute use label instead.
        if (
            !$this->config->has('name') &&
            in_array($this->getType(), ['accordion', 'message', 'tab'])
        ) {
            $key = $this->config->get('label');
        } else {
            $key = $this->config->get('name');
        }

        $key = sprintf('%s_%s', $this->parentKey, Key::sanitize($key));

        $this->key = $key;

        return $key;
    }
public function getKey(): string
    {
        if ($this->key) {
            return $this->key;
        }

        // If the user has set a custom key.
        if ($this->config->has('key')) {
            $key = Key::validate($this->config->get('key'), 'field');

            $this->key = $key;

            return $key;
        }

        // For fields which doesn't require name attribute use label instead.
        if (
            !$this->config->has('name') &&
            in_array($this->getType(), ['accordion', 'message', 'tab'])
        ) {
            $key = $this->config->get('label');
        } else {
            $key = $this->config->get('name');
        }

        $key = sprintf('%s_%s', $this->parentKey, Key::sanitize($key));

        $this->key = $key;

        return $key;
    }
public function getKey ( ) : string { if ( $ this -> key ) { return $ this -> key ; } // If the user has set a custom key. if ( $ this -> config -> has ( 'key' ) ) { $ key = Key :: validate ( $ this -> config -> get ( 'key' ) , 'field' ) ; $ this -> key = $ key ; return $ key ; } // For fields which doesn't require name attribute use label instead. if ( ! $ this -> config -> has ( 'name' ) && in_array ( $ this -> getType ( ) , [ 'accordion' , 'message' , 'tab' ] ) ) { $ key = $ this -> config -> get ( 'label' ) ; } else { $ key = $ this -> config -> get ( 'name' ) ; } $ key = sprintf ( '%s_%s' , $ this -> parentKey , Key :: sanitize ( $ key ) ) ; $ this -> key = $ key ; return $ key ; }
Get the field key.

@return string
Get the field key .