BitPoet Posted December 20, 2018 Share Posted December 20, 2018 33 minutes ago, Gadgetto said: My question was regarding 'fieldgroups' and how they interact with fields and templates when installing things via API. Fieldgroups currently are just an additional layer of "glue" between templates and fields, and for most they are just a few additional lines to write when assembling templates through the API. There are a few points where that additional layer can add some really nice magic to PW, but even most PW module developers never come across these. For everyone not deeply into obscure PW vodoo magic, creating a template with fields is always: Create a template Create a fieldgroup with the same name as the template Create your fields, save them and add them to the fieldgroup Save the fieldgroup Set the fieldgroup in the template Save the template Of course, you can reorder the steps as long as the objects are created before being used and saved after being changed. 9 minutes ago, Gadgetto said: Are Fieldgroups required for adding fields to templates? What are these for? Yes, they are. As written above, they are just a necessary glue. 7 1 Link to comment Share on other sites More sharing options...
Gadgetto Posted December 20, 2018 Author Share Posted December 20, 2018 1 hour ago, BitPoet said: Fieldgroups currently are just an additional layer of "glue" between templates and fields, and for most they are just a few additional lines to write when assembling templates through the API. There are a few points where that additional layer can add some really nice magic to PW, but even most PW module developers never come across these. For everyone not deeply into obscure PW vodoo magic, creating a template with fields is always: Create a template Create a fieldgroup with the same name as the template Create your fields, save them and add them to the fieldgroup Save the fieldgroup Set the fieldgroup in the template Save the template Of course, you can reorder the steps as long as the objects are created before being used and saved after being changed. Yes, they are. As written above, they are just a necessary glue. Hey, great - that's exactly the information I needed! Thank you! 2 last questions: 1) What if I'd like to add fields after the template was saved and how can I add them to the same fieldgroup? 2) Is there always only one field group per template or will/can there be more than one? Link to comment Share on other sites More sharing options...
BitPoet Posted December 20, 2018 Share Posted December 20, 2018 10 minutes ago, Gadgetto said: 1) What if I'd like to add fields after the template was saved and how can I add them to the same fieldgroup? Just add them to the template's fieldgroup. $fg = $template->fieldgroup; $fg->add($field); $fg->save(); 12 minutes ago, Gadgetto said: 2) Is there always only one field group per template or will/can there be more than one? It is save to assume that there is only one fieldgroup, the one which you can access through $template->fieldgroup (or $template->fields, which is just an alias). 1 1 Link to comment Share on other sites More sharing options...
Gadgetto Posted December 20, 2018 Author Share Posted December 20, 2018 1 minute ago, BitPoet said: Just add them to the template's fieldgroup. $fg = $template->fieldgroup; $fg->add($field); $fg->save(); It is save to assume that there is only one fieldgroup, the one which you can access through $template->fieldgroup (or $template->fields, which is just an alias). Thanks a lot! Thats all for now! ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now