Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
axoloth opened this issue Nov 7, 2022 · 0 comments
Open

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

axoloth opened this issue Nov 7, 2022 · 0 comments

Comments

@axoloth
Copy link

axoloth commented Nov 7, 2022

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant