bolt / users

Bolt users extension.
MIT License
8 stars 7 forks source link

Fields in content type don't appears in /profile/edit #27

Open axoloth opened 1 year ago

axoloth commented 1 year ago

Hello,

I want to set up profile editing from the frontend. As written in the doc, I created a contentType

members:
    slug: members
    name: Members
    singular_name: Member
    title_format: "{author.username}"
    fields:
        dob:
            type: date
        adresse:
            type: text
        ville:
            type: text
     viewless: true

Then I inserted the following lines into bolt-userextension.yaml:

groups:
    ROLE_MEMBER:
        redirect_on_register: homepage
        redirect_on_login: /
        initial_status: enabled
        contenttype: members
        allow_profile_edit: true 
        profile_edit_template: 'edit_profile.twig'

And finally my twig file edit_profile.twig contains the following lines:

    <form method="post">
        {% for field in record.fields %}

            {{ dump(field) }}

            <label for="fields[{{ field.name }}]"></label>
            {% if field.type === 'text' %}
                <input type="text" name="fields[{{ field.name }}]" value="{{ field.parsedValue }}" />
            {% elseif field.type === 'textarea' %}
                <textarea name="fields[{{ field.name }}]">{{ field.parsedValue }}</textarea>
            {% elseif field.type === 'checkbox' %}
                <input type="checkbox" name="fields[{{ field.name}}]" value="{{ field.parsedValue }}" />
            {% elseif field.type === 'date' %}
                <input type="date" name="fields[{{ field.name }}]" value="{{ field.parsedValue }}" />
            {% endif %}
        {% endfor %}

        <!-- The input fields below are required for Bolt to process the form. Do not change them -->
        <input type="hidden" name="_csrf_token" value="{{ csrf_token('editrecord') }}">
        <input type="hidden" name="_edit_locale" value="{{ user.locale }}">
        <input type="hidden" name="status" value="published">
        <input type="submit" value="save">
    </form>

Nothing is displayed, according to the DUMP, record.fields only contains the slug :

[Bolt\Entity\Field\SlugField]{
  -id: 29
  +name: "slug"
  -sortorder: 0
  -version: null
  -content: [Bolt\Entity\Content]...
  -parent: null
  -fieldTypeDefinition: [Bolt\Configuration\Content\FieldType]
  -useDefaultLocale: true
  #translations: [Doctrine\ORM\PersistentCollection]
  #newTranslations: null
  #currentLocale: "fr"
  #defaultLocale: "fr"
}

Any ideals ?