Compulsory choose field of gender isn't working in SMF 2.0

Started by jsx, August 22, 2017, 02:53:10 PM

Previous topic - Next topic

jsx

Hi,

I wanted to do the compulsory choose field of gender during the registration, but unfortunately this function isn't acting correctly in SMF 2.0.14.

It's in:

Features and Options > Profile Fields > Custom Profile Fields

And I did like this:

I wrote a name in "Profile Section" I choose option "Forum Profile", in "Show on Registration" I choose option "Yes, and require entry", in "Field Type" I choose option "Select Box" and made such a fields:

First empty field (as in the standard option of gender in SMF)
Second field: Man
Third field: Woman

And though of the correct configuration of this option this option isn't fulfilling its function, since while creating the new account it will be possible to create the account without choosing the gender, although in placing is emphasized requiring option choosing one gender. Can you do a solution how to fix this bug? And you could fix this bug in the future and give SMF 2.0.15 without this bug.

And I would like to ask if can you enable the edition of standard fields of SMF profiles in the version 2.0.15? I think that these standard fields of profiles should be editable so that it is possible to take advantage already of ready fields of profiles that is: Location, Gender, so that it is possible for them to place the need to write the name of the location down and the need for choice of the gender during the registration.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

jsx

Where can I report a suggestion into it?

QuoteAnd I would like to ask if can you enable the edition of standard fields of SMF profiles in the version 2.0.15? I think that these standard fields of profiles should be editable so that it is possible to take advantage already of ready fields of profiles that is: Location, Gender, so that it is possible for them to place the need to write the name of the location down and the need for choice of the gender during the registration.

Will be really good if SMF programmers already enabled the edition of standard fields of the profile, because for what I need to make a new field of gender and location? If I can use a ready fields, but I would like to that there is a possibility of their edition and setting the need to choose during the registration.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Just looking at this again, required field works with radio buttons as long as there is no default button selected.  Still can't make it work with select box.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Suki

My memory isn't as good as it used to be so don't quote me on this.

It isn't a trivial change and it won't be added even if it was. I remember there was an old report about this or a similar issue and if I didn't implemented it back when I worked on migrating the fields to custom profile fields I'm pretty sure there was a heavy reason for it.  Or maybe I did, again, Its difficult to remember all the changes applied over the years.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Sir Osis of Liver

Hey, Suki, good to see you.  Do you know why required field doesn't work for select?  Been picking through code for an hour, can't find it.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Suki

I don't have any code at hand or a test forum but it must be because SMF also allows multiple selects? or because SMF treats all fields the same and selects needs some special treatments.  I did some work on this for 2.1, might be worth to take a look at it. I can't remember the exact file/line where profile fields are saved, sorry.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Sir Osis of Liver

Tried this, should work but doesn't -

Subs-members.php



// No name?!  How can you register with no name?
if (empty($regOptions['username']))
$reg_errors[] = array('lang', 'need_username');

// Require gender
if (empty($regOptions['gender']))
$reg_errors[] = array('lang', 'need_gender');

// Spaces and other odd characters are evil...



Does not accept any selection.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

jsx

It cannot be this way. For what is possibility of choice option thanks to which select field is required do choose/entering during the registration. At present option "Yes, and require entry" for "Select Box" isn't acting the way it should.

Sir Osis of Liver

It is my understanding that HTML assumes a selected option in a select box, even if there isn't one, so there's always a required entry.  There should be a way to fix it, but haven't found it yet.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Ok, here's how to make the default gender field required -

Register.php



// Set the options needed for registration.
$regOptions = array(
'interface' => 'guest',
'username' => !empty($_POST['user']) ? $_POST['user'] : '',
'gender' => !empty($_POST['gender']) ? $_POST['gender'] : '',



Subs-Members.php



// !!! Separate the sprintf?
if ($smcFunc['db_num_rows']($request) != 0)
$reg_errors[] = array('lang', 'email_in_use', false, array(htmlspecialchars($regOptions['email'])));
$smcFunc['db_free_result']($request);

/// Require gender
if (empty($regOptions['gender']))
$reg_errors[] = array('lang', 'need_gender');



Login.english.php (or whichever language you're using)



// Registration form.
$txt['registration_form'] = 'Registration Form';
$txt['need_username'] = 'You need to fill in a username.';
$txt['need_gender'] = 'You must select your gender.';



Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

jsx

What am I supposed to do with these codes? Because you didn't write what it is necessary to do. If it is a solution whether it will be fixed in the version 2.0.15?

Kindred

no, it will not be changed in 2.0.15 maybe later.... but possibly not
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sir Osis of Liver

Find the first line in each code block, you'll see the where the gender code needs to be added.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

jsx

Quote from: Kindred on August 27, 2017, 02:27:03 PM
no, it will not be changed in 2.0.15 maybe later.... but possibly not

Will fix it, what's a problem with that? You made a function and it's usfull.. other developers fixed reported bugs in next release of software. Sir Osis of Liver give a solution to this bug so you have a ready solution and what's a problem to will implement it in next release of SMF?

Quote from: Sir Osis of Liver on August 27, 2017, 10:57:26 PM
Find the first line in each code block, you'll see the where the gender code needs to be added.

Thanks for solution this bug. :)

Kindred

because 2.0.15 is already in process and adding more crap to it will just delay it further...

as for future beyond that...   maybe, maybe not...    traditionally, point releases for SMF do not include bug fixes except in critical cases. Security and functional patches (like https and php7, etc) are all that get done to point releases.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: