PWaddict Posted April 29, 2018 Share Posted April 29, 2018 On my template's "Required field action" is set to Unpublish the page. I have a Page Table field inside that template with the condition "Required only if". So when a checkbox is checked the Page Table field is required. The problem is that if the checkbox is unchecked so the Page Table isn't required when I save the page it gets unpublished with the error: "Session: Page unpublished because field "test_pagetable" is required" then I can publish the page again without issues then if I save the page again it gets unpublished with the above error and so on... Link to comment Share on other sites More sharing options...
PWaddict Posted April 29, 2018 Author Share Posted April 29, 2018 @Juergen Can you please help me to fix this with a hook? I'm trying to change the required attribute to 0 of my pagetable field right before the page is saved but it doesn't work: $wire->addHookBefore('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments(0); $field = $page->mypagetable; if($page->template == 'mytemplate' && !$page->mycheckbox) { $field->required = 0; } }); Link to comment Share on other sites More sharing options...
Robin S Posted May 1, 2018 Share Posted May 1, 2018 On 30/04/2018 at 2:22 AM, PWaddict said: I have a Page Table field inside that template with the condition "Required only if". So when a checkbox is checked the Page Table field is required. What rule did you enter in the "Required only if" input? I tested it with a checkbox field and couldn't reproduce the issue. Link to comment Share on other sites More sharing options...
PWaddict Posted May 1, 2018 Author Share Posted May 1, 2018 10 minutes ago, Robin S said: What rule did you enter in the "Required only if" input? I tested it with a checkbox field and couldn't reproduce the issue. Yes the rule is: mycheckbox=1 Have you selected the "Unpublish the page" on Required field action under Advanced on the template? You save the page over and over with UNCHECKED checkbox and the page doesn't unpublished??? Link to comment Share on other sites More sharing options...
Robin S Posted May 1, 2018 Share Posted May 1, 2018 I see the issue now. It's not related to PageTable fields as such, and it affects both the "Restore the previous value" and "Unpublish the page" options. I'll add a comment in the GitHub issue. 1 Link to comment Share on other sites More sharing options...
PWaddict Posted May 1, 2018 Author Share Posted May 1, 2018 I fixed it. The solution is posted in the GitHub issue. Link to comment Share on other sites More sharing options...
PWaddict Posted May 3, 2018 Author Share Posted May 3, 2018 It has been properly fixed. More info here. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now