input_validate not called for new profile field?

Started by dev9999, November 28, 2016, 12:19:46 PM

Previous topic - Next topic

dev9999

I added a new field that users can edit in the Forum Profile section. I need to get the POST results, validate them, and persist them to the database.

Here's my profile field definition (Profile-Modify.php):


'equipper' =>  array(
    'type' => 'callback',
    'callback_func' => 'equipper',
    'preload' => 'profileLoadEquippedItems',
    'input_validate' => 'profileSaveEquippedItems',
),


My questions:
1. My input_validate function never gets called. What could cause this?
2. What is the flow for storing profile field information? Please walk me through the code execution from clicking "Change profile", up to the database update.
3. I can see that the input_validate functions get called in saveProfileFields(). However, if I echo a string at the start of this function, it almost never gets displayed on my page. Why?

Using SMF version 2.0.12.

dev9999

All right. I figured it out. If anyone is wondering:

1. The input_validate function does not get called unless the POST data contains the key of the profile field. I had to add a hidden input field to the template with name="equipper" for the validator to pick it up.  Eg.:
Code ("Profile.templates.php/template_profile_equipper()") Select

<input type="hidden" name="equipper">


2. When the submit button is clicked, Profile.php/ModifyProfile() parses the parameters, in this particular case the params are set to use the forumProfile area and save action. Then it calls the saveProfileFields() function in Profile-Modify.php, which calls the appropriate input_validate functions. I'm not really sure where the correct place is to update the database. I'm just going to put it in my input_validate function (profileSaveEquippedItems() for me).

3. I'm still not sure why echo was not working.

Shambles

Thanks for the feedback/update. I was following this issue...


A lot of my own diagnostic echo's never worked - I put it down to the output buffers (OB) not being open.

dev9999

I have very limited knowledge of PHP and SMF. Is it possible to call ob_start() before using echo? Do you know any other good methods for debugging SMF?

Advertisement: