Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Add always_save field config to allow overriding of conditional field data flow - #6387

Merged
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config
Aug 17, 2022
Merged

Add always_save field config to allow overriding of conditional field data flow#6387
jasonvarga merged 8 commits into
3.3from
feature/always-save-field-config

Conversation

@jesseleite

Copy link
Copy Markdown
Contributor

As documented here, field conditions have the following data flow behaviour:

Only visible fields are submitted with your form data. This allows you to control data flow, and conditionally apply validation to visible fields when needed.

We've talked about this a bunch, but never implemented it. This PR allows a user to override the default data flow behaviour on conditional fields with a setting:

CleanShot 2022-07-27 at 16 25 22

Note: You could already override this data flow behaviour by using a revealer field (as mentioned in the revealer docs), but this allows you to override data flow behaviour on any conditionally hidden fields, regardless of how your conditions are set up.

Closes#6386

@niktwenty3

Copy link
Copy Markdown

Hey @jesseleite - Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

To test I created a simple alignment interface. It consists of a button group that has 3 breakpoint options (Small, Medium, Large) and 3 button groups for each one of those breakpoints that control alignment.

In my test I set the position for the SM breakpoint to left, MD to center, and LG to right.

When I hit the save button on the backend it only saves the last visible option.

control-example

I'm adding my fieldset yaml bellow and the page content yaml of my test.

title: Alignfields:
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'
---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659000923align_control: lgpos_lg: rightpublished: true
---

I have some Vue experience so I'll try to take a deeper look at the validation js file to see if I can get more information but right now I have to switch to other work :)

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Pulled your branch under my local vendor folder to test and it doesn't appear to work as expected.

@niktwenty3 Did you also build the JS though?

@niktwenty3

Copy link
Copy Markdown

Yes, I thought about that too after my initial comment. Now that I had some more time I run npm run production in vendor/stamatic/cms/ to rebuild the modules. Still, the same end result. But, if it works on your end, then I'm definitely missing something.

Still looking into it, but, I did take screenshots from the Vue Dev tools just in case and I'm adding them here.

VueX-Actions-Save

VueX-Mutation-Info

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

But, if it works on your end, then I'm definitely missing something.

@niktwenty3 I just tried your fieldset example, and it seems to save fine for me...

pos_sm: leftpos_md: centerpos_lg: right

Once you rebuild the JS, it needs to go in public/vendor/statamic. When working in sandbox apps, I symlink my assets in, so that I can npm run watch from my cms repo, etc...

CleanShot 2022-07-28 at 12 31 25

@niktwenty3

Copy link
Copy Markdown

If it works on your end, then it's definitely me. I tried your setup above but I still didn't get it to work on my end. I'll start a fresh project tomorrow morning to make sure I didn't miss anything.

Pasting bellow my setup just to be safe.

Steps I took:

  1. Cloned statamic CMS repo
  2. Installed required npm modules
  3. Run npm run watch and then npm run frontend-watch to build the app
  4. Created symbolic links like your example
www-data@5f54c328a0fc:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
www-data@5f54c328a0fc:/app/cms$ ls -la ../vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 28 21:36 .
drwxr-xr-x 63 www-data www-data 4096 Jul 26 12:37 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 28 21:36 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy
www-data@5f54c328a0fc:/app/cms$ ls -la ../public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 28 21:37 .
drwxr-xr-x 3 www-data www-data 4096 Jun 29 20:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 28 21:37 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 28 21:37 frontend -> /app/cms/resources/dist-frontend

YAML file after I save.

---
id: 91f2c3b5-8e75-4a0a-b458-74c2fd80b778blueprint: pagestitle: 'Test align'updated_by: 731a1049-8fd7-4fed-9d24-3b14c51810caupdated_at: 1659044513align_control: lgpos_lg: rightpublished: true
---

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Good morning :) Woke up, made some killer coffee and tried again with a fresh install.

Yet still for some reason it does not work on my end.

Here is what was done.

  1. Created a new statamic project using the CLI - statamic new feature-test (no starter-kit)
  2. Cloned statamic CMS
  3. Switched to the feature/always-save-field-config branch
  4. Installed different version of node-sass npm install node-sass@4.14 since on my end it has an issue with the version that's packaged and will not build otherwise and then run npm install for the other dependencies
  5. Built the app npm run production and npm run frontend-prod
  6. Created symlinks
  7. Checked to see current version on the backend and if the new "Always Save" option is there - (Latest version - Always Save showed up)
  8. Edited the "Pages" blueprint and added my fields
  9. Created new page on the backend, tried to save SM|Left MD|Center LG|Right but it would always only save the last visible on the UI option

Saved data

---
id: 9604a11d-c001-46a3-b7c8-886ca667ed39blueprint: pagestitle: Test123author: b0355744-477a-45e6-a5de-748576c781dcupdated_by: b0355744-477a-45e6-a5de-748576c781dcupdated_at: 1659077415align_control: mdpos_md: centerpublished: true
---

Pages blueprint

title: Pagessections:
main:
display: Mainfields:
-
handle: titlefield:
type: textrequired: true
-
handle: align_controlfield:
options:
sm: Smallmd: Mediumlg: Largedisplay: 'Align control'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: true
-
handle: pos_smfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position SM'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals sm'
-
handle: pos_mdfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position MD'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals md'
-
handle: pos_lgfield:
options:
left: Leftcenter: Centerright: Rightdisplay: 'Position LG'type: button_groupicon: button_grouplistable: hiddeninstructions_position: abovevisibility: visiblealways_save: trueif:
align_control: 'equals lg'sidebar:
display: Sidebarfields:
-
handle: slugfield:
type: sluglocalizable: true
-
handle: parentfield:
type: entriescollections:
- pagesmax_items: 1listable: falselocalizable: true

Webserver directory

Folder cms is the downloaded repo.

www-data@23c7023c0b8a:/app$ ls -la
total 496
drwxr-xr-x 15 www-data www-data 4096 Jul 29 06:32 .
drwxr-xr-x 1 root root 4096 Jul 29 06:27 ..
-rw-r--r-- 1 www-data www-data 220 Mar 3 20:37 .editorconfig
-rw-r--r-- 1 www-data www-data 1075 Jul 29 06:25 .env
-rw-r--r-- 1 www-data www-data 1011 Mar 3 20:37 .env.example
-rw-r--r-- 1 www-data www-data 134 Mar 3 20:37 .gitattributes
-rw-r--r-- 1 www-data www-data 211 Mar 3 20:37 .gitignore
-rw-r--r-- 1 www-data www-data 67 Jul 29 06:26 .lando.yml
-rw-r--r-- 1 www-data www-data 181 Mar 3 20:37 .styleci.yml
-rw-r--r-- 1 www-data www-data 1834 Mar 3 20:37 README.md
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 app
-rwxr-xr-x 1 www-data www-data 1686 Mar 3 20:37 artisan
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 bootstrap
drwxr-xr-x 10 www-data www-data 4096 Jul 29 06:33 cms
-rw-r--r-- 1 www-data www-data 2082 Mar 3 20:37 composer.json
-rw-r--r-- 1 www-data www-data 379560 Jul 29 06:25 composer.lock
drwxr-xr-x 3 www-data www-data 4096 Mar 3 20:37 config
drwxr-xr-x 8 www-data www-data 4096 Mar 3 20:37 content
drwxr-xr-x 5 www-data www-data 4096 Mar 3 20:37 database
-rw-r--r-- 1 www-data www-data 616 Mar 3 20:37 package.json
-rw-r--r-- 1 www-data www-data 1202 Mar 3 20:37 phpunit.xml
-rwxr-xr-x 1 www-data www-data 1689 Mar 3 20:37 please
drwxr-xr-x 6 www-data www-data 4096 Jul 29 06:25 public
drwxr-xr-x 9 www-data www-data 4096 Jul 29 06:34 resources
drwxr-xr-x 2 www-data www-data 4096 Mar 3 20:37 routes
-rw-r--r-- 1 www-data www-data 563 Mar 3 20:37 server.php
drwxr-xr-x 7 www-data www-data 4096 Mar 3 20:37 storage
-rw-r--r-- 1 www-data www-data 252 Mar 3 20:37 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 Mar 3 20:37 tests
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:31 users
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 vendor
-rw-r--r-- 1 www-data www-data 1260 Mar 3 20:37 webpack.mix.js
www-data@23c7023c0b8a:/app/cms$ git status
On branch feature/always-save-field-config
Your branch is up to date with 'origin/feature/always-save-field-config'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
no changes added to commit (use "git add" and/or "git commit -a")

Symlink for CMS

www-data@23c7023c0b8a:/app$ ls -la vendor/statamic/
total 12
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:35 .
drwxr-xr-x 62 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 8 Jul 29 06:35 cms -> /app/cms
drwxr-xr-x 3 www-data www-data 4096 May 4 18:41 stringy

Symlinks for CP/Frontend

www-data@23c7023c0b8a:/app$ ls -la public/vendor/statamic/
total 8
drwxr-xr-x 2 www-data www-data 4096 Jul 29 06:36 .
drwxr-xr-x 3 www-data www-data 4096 Jul 29 06:25 ..
lrwxrwxrwx 1 www-data www-data 23 Jul 29 06:36 cp -> /app/cms/resources/dist
lrwxrwxrwx 1 www-data www-data 32 Jul 29 06:36 frontend -> /app/cms/resources/dist-frontend

The only thing I can tell I might be doing different is installing node-sass so that I can build the app. Other than that I have no idea why I can't get it to work on my end xD - Still I'm determined to figure it out :)

@niktwenty3

niktwenty3 commented Jul 29, 2022

Copy link
Copy Markdown

Update - managed to get it working on the fresh install. No idea why though. :/

I'll put my details here for future prosperity.

After I had done all the steps in the previous comment I went and run npm dev on /app. But since I had symbolic links for cms, cp, and frontend, it messed my CP a bit(1). The pages item disappeared from the collections menu. I logged into my container, removed the symlinks, rebuilt the cms files in /app/cms, and then recreated the symlinks. Now it works and everything looks ok. :/

It's definitely a me thing xD - I'll try to port it now on the main project :)

(1) npm in installed on my local system (Win11/WSL2) but the symlink paths are on the container I'm using for my tests.

@niktwenty3

Copy link
Copy Markdown

Final comment, I swear xD. Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

We've been wanting to move away from WP for a long time, but, we also wanted to give more design options for marketing people on the backend. With this, we can flesh out a pretty decent page builder for them to toy around :)

PS. Screenshot of some of the components that are being put together.

Test2-‹-Pages-‹-Collections-‹-Statamic

@jesseleite

Copy link
Copy Markdown
ContributorAuthor

Got it working on our main project - rebuilding the files on the root folder on our end was the missing piece. Thanks a lot for the time and replies on this :).

All good, glad to hear!

@jasonvarga

Copy link
Copy Markdown
Member

@jesseleite Can you resolve the merge conflict? It's from #6443

@jasonvarga
jasonvarga merged commit 039b485 into 3.3Aug 17, 2022
@jasonvarga
jasonvarga deleted the feature/always-save-field-config branch August 17, 2022 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save always config field

3 participants

@jesseleite@niktwenty3@jasonvarga