I don’t believe that it is a problem with the classExtender plugin. However I added a checkbox and it does not seem to want to populate. The other inputs populate just fine and I have taken the checkbox input name and put it in a placeholder and the value from the database table comes through, but the js for the CMS that adds the hidden input above doesn’t seem to recognize it as a checkbox. Don’t know if I am missing something or if there is an error. This is the first time this has happened to me after using this plugin a few times before with such no problems.
This is the checkbox in the ‘MyExtraUserFields’ chunk:
<div class="x-form-item x-tab-item">
<div class="x-form-check-wrap" id="ext-gen141">
<input type="checkbox" autocomplete="off" id="maintMember" name="maintMember" class="x-form-checkbox x-form-field" value="1">
<label for="maintMember" class="x-form-cb-label">This Customer is currently on the Maintenance Plan</label>
</div>
</div>
For the sake of being thorough here is the value in the ‘MyExtUserSchema’:
If you want your checkbox to look and behave like the other ones, you probably have to use Javascript.
Put a wrapper-div into the chunk “MyExtraUserFields” <div id="mycheckbox-wrapper"></div> and then maybe something like this into the plugin:
Then use a snippet (new or existing) to check the value from the DB and replace the cb_checked placeholder with checked if the value is not empty. Be sure the snippet is above the checkbox, and called uncached.
if (!empty ($value) ) {
$modx->setPlaceholder('cb_checked', 'checked');
}
The problem with this approach compared to the one with Javascript is, that when the checkbox is unchecked, $_POST['maintMember'] is not set on saving.
Sry forgot to mention that the checkbox is not updating the value in the database table either, even though the name is correct, so something is not connecting somewhere
Yep that works, since the MODX UI javascript didn’t do that automatically on page load like it has every other time on every other site I’ve used it on I still find weird.