Jump to content

"Profile not saved" problem


hellomoto
 Share

Recommended Posts

I posted about this before and nobody had any input. I started again from scratch on account of this mysterious problem, and I cannot figure out how to even troubleshoot it. I really don't want to have to start it ALL over again; that'd make 3 different copies going of the same project.

No particular errors are given, just that it won't save. It does seem like both times this happened after adding a page field to the user template, relating the user to an office location. If I remove the field, I am still unable to save profiles. When this first happened I removed all the custom fields from the user template and disabled every module one by one. Never again could I save profiles.

Link to comment
Share on other sites

I would think relating users to other pages would be a fairly common requirement too, so... if it is that... 1. why won't it work when I remove the field, and 2. why would it even break my user profile saving capability in the first place? How can fix this???? I don't want to start over again.

Link to comment
Share on other sites

Welcome to ProcessWire, @hellomoto.

Have you taken the time to read up on the available ProcessWire documentation?  I hope you know that you can also do a Google search of the forum and get many of the answers that you have been asking.  Have you tried out the Skyscraper demo yet?  Do you fully have a good understanding of ProcessWire fields, templates and structure?

I may be wrong (and please forgive me if I am), but you seem to be running before you have learned to walk.  PW is a great platform, however everyone needs to take time to digest the many different issues that come with learning a new system.

This forum is a remarkable place, where there are many people willing to help you.  I am only bringing this up because I believe that if you spend a little more time researching what's already available, you will find the answers to most of your questions.

 
I would think relating users to other pages would be a fairly common requirement too, 

You are indeed correct about the above statement.  There is a multitude of documentation and forum posts that detail how this works (to include examples).

I wish you the best with becoming familiar with ProcessWire.

Best Regards,

Charles

Link to comment
Share on other sites

Hey thanks for the welcome. I have definitely read through much of the documentation, forums, Google searched extensively, and tried and inspected (not that extensively but somewhat) several of the site profiles already, and yes I understand the PW structural fundamentals. I have a lot going on in this site already. I put off adding this field because that's when it happened last time, and I had to put it all back together, and then some, and now I added this field again and again I have this issue and nowhere in the documentation that I have seen does it say anything about this not being ok to do. 

So... this is just a freak incident it seems (except for that this is the second time, so.. 2x freaky, but I still have no answers), and I am hoping that since there doesn't seem to be anything in the documentation about this error, or anywhere in the forums, and no additional information other than the profile not saving is provided, that maybe somebody in these great forums might be able to help. Hence, this, and my last post about this. I looked at ProcessProfile.module and don't see any reason the profile wouldn't be saving. It's just an unexplained error. 

Like, I simply did this, nothing should be wrong with it, if something is, and I'm not doing this right, please do tell: I have /about/locations/ with children location pages. These are public, with frontend templates... if it matters... So I then I add a page field to the user template, office_location, with template=location for selector. The thing is, it works. I was able to set locations for all my users with roles=broker. However... that I did by editing the users from my superuser account, and then next thing I know, I check if I can save my profile, and I can't, and neither can I logged in as anyone else. So if page fields can be used in user templates, and this is in fact a commonly done thing, why is this happening to me, what about that is wrong that I did? Why does this break the profiles? Seems crazy to me, but there must be something I'm missing here, I just wish I knew what.

Link to comment
Share on other sites

I read a post somewhere before when I was trying to find out about this, where the guy was creating corresponding like frontend profile pages, separate from the users themselves, to store additional profile data. I know this is totally a possibility, or a number of other ways, I guess. PW, endless possibilities. But I thought I would just do it directly. I suppose I might as well take that same route though, for the same reason: not to corrupt the native user template/variable... I mean it is slightly more time consuming, but in the long run if this is going to happen it'll actually save me a ton of time. I am curious about the answer to this question but... I could just try another way. I guess I'll go look for that thread again and see what's good, how he does it...

Link to comment
Share on other sites


Thanks for trying it out. I'm using 2.5. Debug was set to false... =\ But so I went back to the screwy installation and set its config->default to true, saved my profile successfully, though sans the supposed trouble field. Then I set config->debug back to false and could still save my profile... strange... 

Then, once I added the office_location


field back to the user template, I got "Profile not saved" again. I set debug to true and it says: 

Session: Warning: dependency field 'roles' is not present in this form.

above the regular "Profile not saved" red message.

So I removed the visibility selector, 'roles!=37'. Now when I try to save my profile, it just says:

Session: Profile not saved

...

You did add the field to be editable via the edit-profile screen right? Not just editing the user page? Like you add the field to the template, then make it editable in the profile via ProcessProfile config, then go to /processwire/profile/ (or whatever you have as your admin path if not processwire) and you are able to save it?

Link to comment
Share on other sites

“Profile not saved” usually happens when you have invalid input in one of your fields. I can assure you that adding fields to the user template as well as letting users edit them from their profiles works fine. Even with page-select fields. Unfortunately, it working well makes it hard for us to reproduce your error, and it’s hard to debug it over the internet with such a vague error message. I’m sure it will get solved in time.

Can you tell us exactly what fields you added and how they’re configured?

Also, perhaps looking at the current values of these fields on the database might give you a clue?

Link to comment
Share on other sites

Thanks for the reply, Jan. Sorry about the vagueness. Understandable that that error would come up due to invalid input, but now it's not saying for which field?

It did just say that the field 'roles' is not present, which I know... so I removed that specification from the visibility, but then I can't restrict visibility based on user role(s)? 

Then I remove the field and again it only says, "Session: Profile not saved".

Link to comment
Share on other sites

Yeah, I just added a bogus display dependency to my own page field and now I’m pretty sure I’ve screwed my site up the same way as yours :D I’ll try to track it down tomorrow.

Steps to reproduce:

Add page field to user template (works)

Enable it for profile editing (works)

Set a dependency (Profile not saved error)

To confirm what you’ve already said, removing the dependency doesn’t work. Even removing the field from the template, clearing all values doesn’t work. Neither does re-adding the field. Pretty nasty, this.

Link to comment
Share on other sites

To answer your question about restricting the visibility. The dependencies are managed in a "in this form" fashion, so the fields your settings depend on must be present in the form, as the form isn't deeply linked to a specific page. I currently don't know if adding the roles field with visibility set to not editable / not visible would solve this.

  • Like 1
Link to comment
Share on other sites

Does your problem persist after removing the dependency, logging out and back in again? If I do that, the error is gone. It seems that the error just doesn’t get cleared properly.

To fix this right now, you can hack the core. Open the file wire/modules/Process/ProcessProfile/ProcessProfile.module and change the following line:

if(count($form->getErrors())) {

To this:

if(count($form->getErrors(true))) {

The argument clears the errors that occurred during form validation. It should be safe. The errors are not used anywhere else as far as I can tell.

Instead of hacking the core directly, it’s probably better to use the new multiple-modules feature. Funnily enough, Ryan uses the exact same file as an example in his blog post.

  • Like 4
Link to comment
Share on other sites

  • 2 years later...

I just ran into this same issue. I tried to make a field dependent on one of the roles and it broke the profile, even though neither the roles field or the dependent field were visible in the profile at all.

I created a copy of the ProcessProfile module under /site/modules/ and replaced this:

if(count($form->getErrors())) {
  $this->error($this->_("Profile not saved")); 
  return;
}

With this:

$errors = $form->getErrors();
if(count($errors)) {
  if(count($errors) == 1 && strpos($errors[0], 'showIf') !== false) {
  	// Everything is okay
  }
  else {
    $this->error(implode('; ', $errors)); // Show the actual errors instead of just a generic message
    return;
  }
}

This way if there is only one error message and it is related to a 'showIf' field dependency, the form will save anyway.

  • Like 1
Link to comment
Share on other sites

  • hellomoto changed the title to "Profile not saved" problem

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...