# Getting a field's name

**URL:** <https://community.hubspot.com/t/getting-a-fields-name/73392>\
**Category:** CMS Development\
**Created:** [January 20, 2023, 2:39pm UTC](https://community.hubspot.com/t/getting-a-fields-name/73392 "2023-01-20T14:39:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FMontenegro](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@FMontenegro](https://community.hubspot.com/u/FMontenegro)\
**Post date:** [January 20, 2023, 2:39pm UTC](https://community.hubspot.com/t/getting-a-fields-name/73392/1 "2023-01-20T14:39:48Z")

</div>

Hello all,

I’m new to HubSpot/HubL and I’m trying to build my first module (as a learning activity).

The issue I’m having was brought up on [https://community.hubspot.com/t5/CMS-Development/Get-form-fields-name-through-Hubl/m-p/297619#M14014](https://community.hubspot.com/t5/CMS-Development/Get-form-fields-name-through-Hubl/m-p/297619#M14014) - HOWEVER it seems that at the time (2019) it was just not possible to access a field’s name like that?

I wonder if this changed (couldn’t find anything online so far)? So I have a group and what I’m trying to achieve is getting the field’s name since I’ll be using it as part of the name of a class.

EDIT: The field is of type URL (not sure if this will make a huge difference?)

Something like

```lia-code-sample
{% for i in module.field_group %}
 <span class="prefix-{{i.name}}"></span>
{% endfor %}

```

This is obviously not exactly my use-case, but it sums it up nicely. I want the name of the field, as estated on “HubL variable name” on the Design Tools fields section (to the right). So this is a meta-data thing.

Thank you all!

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [January 23, 2023, 2:38pm UTC](https://community.hubspot.com/t/getting-a-fields-name/73392/2 "2023-01-23T14:38:24Z")

</div>

The link you shared is about getting the names of fields from a _form_ used in a module not the name of module fields themselves. To get the name you can use a _key, val for loop_; **key** being the field name (don’t forget to add **.items()** to the end of the group variable as this is what makes it possible to iterrate through the keys).

```lia-code-sample
{% for key, val in module.field_group.items() %}
 <span class="prefix-{{ key }}"></span>
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![FMontenegro](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@FMontenegro](https://community.hubspot.com/u/FMontenegro)\
**Post date:** [January 30, 2023, 2:09pm UTC](https://community.hubspot.com/t/getting-a-fields-name/73392/3 "2023-01-30T14:09:37Z")

</div>

Thank you very much! I was missing the .items() at the end, which seemed to be returning only the values. P.S.: It (logically) also worked as

```lia-code-sample
{% for i in module.field_group.items() %}
 <span class="prefix-{{ i.key }}"></span>
{% endfor %}

```
