jan-vince / smallrecords

OctoberCMS plugin to store and manage records and lists
MIT License
30 stars 11 forks source link

How do I get the value of a custom field? #90

Open WebProviderNGO opened 3 years ago

WebProviderNGO commented 3 years ago

Hi, sorry for the stupid question, but I can't figure out how to get the custom field value :)

Twig: {{% for record in records1.items %} {record.custom_field }} {% endfor %}

The value is empty.

These are the fields for entering numbers. This value has been preserved in the database.

jan-vince commented 3 years ago

Not stupid - my docs are far from to be perfect :)

I do not know which part of record you need but look inside a '/components/recorddetail/default.htm' file.

Or send screenshot from record detail in backend.

WebProviderNGO commented 3 years ago

Not stupid - my docs are far from to be perfect :)

I do not know which part of record you need but look inside a '/components/recorddetail/default.htm' file.

Or send screenshot from record detail in backend.

Thank you! With the help of the plugin, I go through the order of the steps to complete the order. I am displaying a list of records from a specific list.

{% for record in records1.items %}
<div class="uk-grid-small uk-flex-middle uk-margin-medium-bottom" uk-grid>
    <div class="uk-width-auto"><span class="uk-badge BadgeSecondary">{{ record.number }}</span></div>
    <div class="uk-width-expand">
        <h3 class="uk-margin-remove uk-text-bold">{{ record.name }}</h3>
        <p class="uk-margin-remove uk-text-muted">{{ record.description }}</p>
    </div>
</div>
{% endfor %}

"record.number" is what I'm trying to get a custom field with a number.

jan-vince commented 3 years ago

So probably '{{record.custom_fields.number}}' ?

WebProviderNGO commented 3 years ago

So probably '{{record.custom_fields.number}}' ?

I think I get it! I have executed: {{ dump(record.toArray()) }}

изображение

custom_repeater is an array, so it should be output as an array. I'm right?

WebProviderNGO commented 3 years ago

This is how it works!

{% for record in records1.items %}
<div class="uk-grid-small uk-flex-middle uk-margin-medium-bottom" uk-grid>
    <div class="uk-width-auto"><span class="uk-badge BadgeSecondary">{% for number in record.custom_repeater %}{{
            number.number }}{% endfor %}</span></div>
    <div class="uk-width-expand">
        <h3 class="uk-margin-remove uk-text-bold">{{ record.name }}</h3>
        <p class="uk-margin-remove uk-text-muted">{{ record.description }}</p>
    </div>
</div>
{% endfor %}
jan-vince commented 3 years ago

Maybe check for a correct type of custom_repeater field as you can add more later.

You can use code from default component.