complex custom field but facing problem
Brought to you by:
jberanek
I have added a custom field to the user table, and I named it "technician" tinyint(1) and it's become check mark and it's working fine.
after that, I make SQL query in the config file to produce an array of technicians and add them to select options.
its working fine but the problem is its printing the technician name plus array key, check the attached image
and I want also to prevent users to see these options, I want only the admins can see these options while they approve the reservation.
I am using the latest version
Regards
this is the code I have added to the config file
The problem is that you are not creating a simple array, which is what I think you want, but an array of associative arrays, which MRBS treats as option groups in the select element.
Instead of
you want
The other thing to note is that the
mysql_functions are deprecated as of PHP 5.5.0 and removed as of PHP 7.0.0. You should instead use mysqli or PDO. The easiest thing to do would be to make use of MRBS's database abstraction class - look at how some other database queries are handled in MRBS - but to do this you will need to wait until they are available. I'd suggest creating your own file called, for example, 'myconfig.inc', adding arequire_once 'myconfig.inc'to the bottom of defaultincludes.inc and then putting your code to populate$select_options['entry.technician_name']in myconfig.inc. It would look something likeAnd that's all the code you'd need (though I haven't tested it). Note that I have used
$tbl_usersinstead ofmrbs_usersas that will cater for changes in the table prefix. You might also want to order your array by changing your query toLast edit: Campbell Morrison 2019-02-03
PS This isn't an MRBS bug. It would be better to raise future such questions as Support Requests. Thanks.
To answer your last question, if you only want admins to be able to see the technician field on the edit_entry form, then you'll have to edit edit_entry.php and change line 1713 from:
to
Ideally you'd also add some code in edit_entry_handler.php to guard against users changing the hidden input on the form.
Great
working fine, thanks mate
and sorry for posting in the wrong section :)
I found an extra bracket placed incorrectly in your last code
I search in edit_entry_handler.php
but I couldn't find where I have to prevent users from showing the hidden input.
and I logged in as a user and inspect the page and didn't find hidden input, I think it's working fine "what do you think?"
It depends on (a) how tech-savvy you think your users are and (b) the impact if they do manage to change the technician name.
If you do want to put in a check then you should add the following code at line 435 of edit_entry_handler.php, ie at the beginning of the
if (isset($id))block:Do you mean like this?
Yes