tzunghaor / settings-bundle

Symfony bundle for storing settings in database with editor GUI
MIT License
5 stars 1 forks source link

Update form not submitting #3

Open tacman opened 2 years ago

tacman commented 2 years ago

I think I'm following the instructions, but when I edit the settings, they're not being saved.

The issue is that $form->isSubmitted() is returning false, even though it looks like it's submitting correctly.

# config/routes/tzunghaor_settings.yaml

settings_scope_search:
  path: '/settings/scope-search'
  controller: 'tzunghaor_settings.editor_controller::searchScope'

settings_edit:
  path: '/settings/edit/{scope?}/{section?}'
  controller: 'tzunghaor_settings.editor_controller::edit'
  defaults:
    collection: 'default'
    fixedParameters: ['collection']
    searchRoute: 'settings_scope_search'

I'm using the BoxSettings as described in the documentation.

# config/packages/tzunghaor_settings.yaml
tzunghaor_settings:
  collections:
    # Each entry under "tzunghaor_settings" configures a setting collection.
    # Use "default" if you define only one collection
    default:
      mappings:
        # I used "default" as mapping name, but it is up to you.
        # You can have multiple mappings
        default:
          dir: '%kernel.project_dir%/src/Settings'
          prefix: App\Settings\

I imagine it's something simple, any ideas on where I should be looking?

tacman commented 2 years ago

I've created a repo that shows the problem:

https://github.com/tacman/settings-demo

tzunghaor commented 2 years ago

Thanks for the demo. In your framework.yaml set http_method_override to true and it should work.

Did you explicitly set that to false, or was it auto-generated?

It seems that I should either update the documentation or check if using PATCH method for the form is worth the hassle.

tacman commented 2 years ago

That was auto-generated.

Thanks!

On Tue, Aug 23, 2022 at 4:10 PM Andras @.***> wrote:

Thanks for the demo. In your framework.yaml set http_method_override to true and it should work.

Did you explicitly set that to false, or was it auto-generated?

It seems that I should either update the documentation or check if using PATCH method for the form is worth the hassle.

— Reply to this email directly, view it on GitHub https://github.com/tzunghaor/settings-bundle/issues/3#issuecomment-1224788157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQNVTGCCU7ODMNOPGTDV2UV2NANCNFSM57L7WBOA . You are receiving this because you authored the thread.Message ID: @.***>

jmwamser commented 11 months ago

I ran into this issue as well. Looking into the Symfony community I found this. https://github.com/symfony/symfony/issues/45278 Sounds like this will be a default moving forward.

here is what my YAML file looks like now.

# config/packages/tzunghaor_settings.yaml
tzunghaor_settings:
  collections:
    # Each entry under "tzunghaor_settings" configures a setting collection.
    default:
      cache: 'cache.app'
      mappings:
        default:
          dir: '%kernel.project_dir%/src/Settings'
          prefix: App\Settings\

framework:
  # the form is not saving, due to default symfony configuration
  # https://github.com/tzunghaor/settings-bundle/issues/3
  # https://github.com/symfony/symfony/issues/45278
  http_method_override: true
tzunghaor commented 10 months ago

Thanks for the tip, @jmwamser. Your comment went a bit under the radar as it was in a closed issue, so I reopened it so that I don't forget about it.