Answers.Body: <p>Craft automatically sets values from the incoming POST data on your <code>Settings</code> model, which means the input <code>name</code> attributes must match <em>exactly</em> (or that the <code>Settings</code> model must expose an appropriate “setter” method).</p>
  <p>It appears that your class property is <code>agreeButtonLabel</code> (not <code>agegateAgreeButton</code>), which means that its field’s macro call should look like this:</p>
  <pre><code>{{ forms.textField({
      label: 'Agree Button',
      name: 'agreeButtonLabel',
      value: settings.agreeButtonLabel,
  }) }}
  </code></pre>
  <p>I suspect this was ultimately just a typo, because you already had the correct property name for the <code>value</code> part of the macro!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-12T19:05:35.633Z
Answers.LastActivityDate: 2023-03-12T19:05:35.633Z
Answers.UserDisplayName: August Miller
Body: <p>After following the &quot;How to build a plugin&quot; from the official CraftCMS docs, I've started extending the Control Panel Template from 1 to multiple fields, all are of the same type string and all &quot;fields&quot; use a simple Textfield</p>
  <p>Here the Model:</p>
  <pre><code>class Settings extends Model {
      public $pluginName = 'AgeGate';
      public $isAgeGateEnabled = true;
      public $minimumAgeAllowed = 10;
      public $agegateTitle = 'Age Verification';
      public $agegateContent = 'Verify your age';
      public $dayPlaceHolder = 'DD';
      public $monthPlaceHolder = 'MM';
      public $yearPlaceHolder = 'YYYY';
  
      public $agreeButtonLabel = 'Enter';
      public $declineButtonLabel = 'Leave';
      public $failureMessage = 'You are not old enough to enter this site';
  
  
      public function defineRules(): array {
          return [
          ];
      }
  }
  </code></pre>
  <p>and here the settings template</p>
  <pre><code>{% import '_includes/forms.twig' as forms %}
  
  {{ forms.textField({
      first: true,
      label: 'Minimum Age Allowed',
      name: 'minimumAgeAllowed',
      value: settings.minimumAgeAllowed
  }) }}
  
  {{ forms.textField({
      label: 'Title of Age Gate',
      name: 'agegateTitle',
      value: settings.agegateTitle
  }) }}
  
  {{ forms.textField({
      label: 'Content of agegate',
      name: 'agegateContent',
      value: settings.agegateContent
  }) }}
  
  {{ forms.textField({
      label: 'Agree Button',
      name: 'agegateAgreeButton',
      value: settings.agreeButtonLabel
  }) }}
  
  {{ forms.textField({
      label: 'Decline Button',
      name: 'agegateDeclineButton',
      value: settings.declineButtonLabel
  }) }}
  </code></pre>
  <p>I don't have any problems saving the first three fields, but when changing the content of the last 2 fields my changes don't get updated.</p>
  <p>I just can't see the reason why certain fields get updated and others not. Did anyone had this issue before?</p>
  <p>Note: defineRules is empty on purpose for testing as currently i don't care about validating input</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-23T19:31:46.567Z
Comments.Text: It looks like your input `name` attributes don't quite match your `Settings` model properties. I see `agegateDeclineButton` in the template, but `agreeButtonLabel` in the model; it _does_ seem like the correct properties are being set back on the input for their `value` attributes, though! (i.e. `settings.agreeButtonLabel`)
Comments.UserDisplayName: August Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-23T19:50:45.067Z
Comments.Text: I see I see.. so the name and value need to be the same.
Comments.UserDisplayName: funkysoul
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-02T22:06:48.740Z
Comments.Text: @funkysoul if that ends up fixing it for you, let us know so August can add it as an official answer!
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-03T13:24:55.653Z
Comments.Text: Hi Brad, yes definitely, Augusts comment was the right answer.
Comments.UserDisplayName: funkysoul
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-03T16:20:29.373Z
Comments.Text: @AugustMiller you're up!
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-12T19:06:26.640Z
Comments.Text: Added! Thanks for the ping. 
Comments.UserDisplayName: August Miller
Tags: <plugin-development><craft4><custom>
Title: Craft 4 Building a Plugin not saving all properties
ThreadText: # Craft 4 Building a Plugin not saving all properties
  
  (Asked by: username_0 on 2023-02-23)
  
  After following the "How to build a plugin" from the official CraftCMS docs, I've started extending the Control Panel Template from 1 to multiple fields, all are of the same type string and all "fields" use a simple Textfield
  
  Here the Model:
  
  ```
  class Settings extends Model {
      public $pluginName = 'AgeGate';
      public $isAgeGateEnabled = true;
      public $minimumAgeAllowed = 10;
      public $agegateTitle = 'Age Verification';
      public $agegateContent = 'Verify your age';
      public $dayPlaceHolder = 'DD';
      public $monthPlaceHolder = 'MM';
      public $yearPlaceHolder = 'YYYY';
  
      public $agreeButtonLabel = 'Enter';
      public $declineButtonLabel = 'Leave';
      public $failureMessage = 'You are not old enough to enter this site';
  
      public function defineRules(): array {
          return [
          ];
      }
  }
  
  ```
  
  and here the settings template
  
  ```
  {% import '_includes/forms.twig' as forms %}
  
  {{ forms.textField({
      first: true,
      label: 'Minimum Age Allowed',
      name: 'minimumAgeAllowed',
      value: settings.minimumAgeAllowed
  }) }}
  
  {{ forms.textField({
      label: 'Title of Age Gate',
      name: 'agegateTitle',
      value: settings.agegateTitle
  }) }}
  
  {{ forms.textField({
      label: 'Content of agegate',
      name: 'agegateContent',
      value: settings.agegateContent
  }) }}
  
  {{ forms.textField({
      label: 'Agree Button',
      name: 'agegateAgreeButton',
      value: settings.agreeButtonLabel
  }) }}
  
  {{ forms.textField({
      label: 'Decline Button',
      name: 'agegateDeclineButton',
      value: settings.declineButtonLabel
  }) }}
  
  ```
  
  I don't have any problems saving the first three fields, but when changing the content of the last 2 fields my changes don't get updated.
  
  I just can't see the reason why certain fields get updated and others not. Did anyone had this issue before?
  
  Note: defineRules is empty on purpose for testing as currently i don't care about validating input
  
  **Tags:** plugin-development, craft4, custom
  
  > **Comments:**
  > **username_1**: It looks like your input `name` attributes don't quite match your `Settings` model properties. I see `agegateDeclineButton` in the template, but `agreeButtonLabel` in the model; it _does_ seem like the correct properties are being set back on the input for their `value` attributes, though! (i.e. `settings.agreeButtonLabel`)  
  > **username_0**: I see I see.. so the name and value need to be the same.  
  > **username_2**: @username_0 if that ends up fixing it for you, let us know so username_1 can add it as an official answer!  
  > **username_0**: Hi username_2, yes definitely, Augusts comment was the right answer.  
  > **username_2**: @username_1 you're up!  
  > **username_1**: Added! Thanks for the ping.   
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-12. Score: 3 | Accepted answer
  
  Craft automatically sets values from the incoming POST data on your `Settings` model, which means the input `name` attributes must match *exactly* (or that the `Settings` model must expose an appropriate “setter” method).
  
  It appears that your class property is `agreeButtonLabel` (not `agegateAgreeButton`), which means that its field’s macro call should look like this:
  
  ```
  {{ forms.textField({
      label: 'Agree Button',
      name: 'agreeButtonLabel',
      value: settings.agreeButtonLabel,
  }) }}
  
  ```
  
  I suspect this was ultimately just a typo, because you already had the correct property name for the `value` part of the macro!
  
  
  ---
  
  