wintercms / wintercms/winter

Disabled fields are submitted and saved

Open
#1,279 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.5k
Forks
246
Avg merge
19h 2m
Merged PRs (30d)
7

Description

Winter CMS Build

1.2

PHP Version

8.1

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

Hi there,

I have a switch field named is_activated in the User form that gets disabled once the user is activated. In my User model, I also have a default value for the attribute is_activated:

public $attributes = [
	'is_banned' => false,
	'is_activated' => false,
	'ldap_authenticated' => false,
];

However, for some reason, when I submit the form (context is always update) the disabled switch is submitted too and the value false is saved for the field is_activated. Thus the user is not activated anymore.

Request payload:
Image

How can I solve? Thanks.

Steps to replicate
  1. Add a switch field.
  2. Disable it somehow.
  3. Submit.
Workaround

The solution, for now, seems to be to not disable form fields.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with a disabled switch field on a User update form, then inspect the request payload and model save behavior. The fix is complete when a disabled field is not submitted or does not overwrite its existing value, while enabled fields continue to save normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb, mysql, php
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.