landitus Posted September 16, 2011 Share Posted September 16, 2011 Hi! I am really stuck with this. I accidentally assigned the fieldgroup 'user' to one of my templates and now I can't remove it cause it says it has permanent fields! I guess I shoudl turn off the advanced settings preference (If anyone can remind me how). How can I change the Fieldgroup from 'user' to my own Link to comment Share on other sites More sharing options...
ryan Posted September 16, 2011 Share Posted September 16, 2011 ProcessWire's API prevents changes to some system templates/fields, so you have to go behind it's back and use a DB query. So to switch it back to the previous fieldgroup, insert this into one of your templates temporarily and view a page using the template (like your homepage): <?php $name = "name-of-template-you-want-to-fix"; $template = $templates->get($name); $fieldgroup = $fieldgroups->get($name); $db->query("UPDATE templates SET fieldgroups_id={$fieldgroup->id} WHERE id={$template->id}"); Once you do that, it should be fixed and you can delete the above code snippet. To turn off advanced mode, edit your /site/config.php and locate the line that says $config->advanced = true; and change it to false. Link to comment Share on other sites More sharing options...
landitus Posted September 16, 2011 Author Share Posted September 16, 2011 Ryan, It worked perfectly!!! Thanks you very much! Link to comment Share on other sites More sharing options...
landitus Posted September 17, 2011 Author Share Posted September 17, 2011 Ryan, I actually had to templates with the same problem, the last one having placed the field "process" by mistake. I tryed to repeat the working code (with different template name in the code") but still get the error about permanent fields. Is this supposed to be like this? PS: I've definitely turned off advanced mode for now! Link to comment Share on other sites More sharing options...
ryan Posted September 18, 2011 Share Posted September 18, 2011 The advanced mode is meant for PW system development, so it'll let you do things that aren't reversible in the API. However, advanced mode won't let you start removing permanent/system fields because then you really could break the system in a way that would be difficult to fix, even from the DB. In your case, you've added a system field, which is something different from changing the fieldgroup of a template. I think this will fix it: <?php $name = "name-of-template-you-want-to-fix"; $field = $fields->get("process"); // or substitute name of field you want to remove $fieldgroup = $fieldgroups->get($name); $db->query("DELETE FROM fieldgroups_fields WHERE fieldgroups_id={$fieldgroup->id} AND fields_id={$field->id} LIMIT 1"); With regard to advanced mode, I don't personally use it (or recommend using it) unless you are developing an addon module and need some advanced feature in a template or field that comes with your module. Advanced mode isn't meant for site development. I may need to clarify that more in the docs. Link to comment Share on other sites More sharing options...
landitus Posted September 18, 2011 Author Share Posted September 18, 2011 It worked! Thanks for the solution Ryan! ;D 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