- Issue created by @jcandan
- πΊπΈUnited States jcandan
I've pushed a couple of commits to the fork (noting here in case someone overrides):
I am still working through some issues:
- I think I need to prevent error message removal when the condition is not met in
\Drupal\conditional_fields\ConditionalFieldsFormHelper::formValidate()
. - It seems the dependentValidate() thinks the condition is "triggered" when it is not.
- The
dependentValidate()
also seems to be explicitly handlingrequired
and!required
. - Not yet sure if it is best to pass the _wrapper in the error key.
- I think I need to prevent error message removal when the condition is not met in
- πΊπΈUnited States jcandan
Fork description
So that the module doesn't depend on Conditional Fields, the logic is provided in a submodule. When enabled, it provides
require_on_publish
as one of the possible#states
.Steps to reproduce
Using the provided fork, you may begin to understand how this might work.
- Install Require on Publish and Conditional Fields.
- Add a boolean field to Basic Page, and a text field.
- Under Structure > Conditional Fields, make the text field required on publish when the boolean field is checked.
- Create a Basic Page.
With the above and the branch as it stands, the required on publish markings are successfully applied. However, the error handling still needs work.
Problems persist
See comment above and comments in code for an understanding of the ongoing problems.
- πΊπΈUnited States jcandan
By adding full support for #states Form API conditions, integration with Conditional Fields β is possible with:
use Drupal\Core\Form\FormStateInterface; /** * Implements hook_conditionalFieldsStates_alter(). * * @see Drupal\conditional_fields\Conditions::conditionalFieldsState * @phpcs:disable Drupal.NamingConventions.ValidFunctionName.InvalidName */ function require_on_publish_conditional_conditionalFieldsStates_alter(array &$states) { // phpcs:enable // A list of supported states that may be applied to a conditional field. $states['require_on_publish'] = t('Required on Publish'); }
- Merge request !24Issue #3530547: Add require on publish #states Form API handling β (Open) created by jcandan
- First commit to issue fork.
- πΊπΈUnited States jcandan
Let's limit the lint fixes to the changed or newly introduced files, please.
The following already exist to fix the lint failures:
- π Fix spelling errors Active
- π Fix eslint issues Active
- πΊπΈUnited States jcandan
This last commit introduced new lint errors; perhaps used the wrong eslint settings.
If you revert
ecb04525 - fixed eslint issues
, you will only need to address the following:/builds/issue/require_on_publish-3530547/web/modules/custom/require_on_publish-3530547/js/states.js 8:15 error Identifier 'legend_span' is not in camel case camelcase 23:13 error Identifier 'legend_span' is not in camel case camelcase 34:13 error Identifier 'legend_span' is not in camel case camelcase
- πΊπΈUnited States jcandan
We're getting closer to a proper roadmap. I have placed this in the queue for 2.1.0.
- π¦π²Armenia hhvardan
Updated the patch to limit ESLint fixes to only the files changed in this issue.
- πΊπΈUnited States jcandan
Added tests. Tests pass, but since the PHPUnit update bug they fail.
Needs review.
- Merge request !36Issue #3530547: Add require on publish #states Form API handling β (Merged) created by jcandan
-
jcandan β
committed 1ec901ff on 2.1.x
Issue #3530547: Add require on publish #states Form API handling
-
jcandan β
committed 1ec901ff on 2.1.x
- Status changed to Fixed
about 1 month ago 6:39pm 26 August 2025 Automatically closed - issue fixed for 2 weeks with no activity.