Support

  1. msreyes
  2. General
  3. Wednesday, September 08 2021, 08:01 PM
I have a field that is 6 numbers.... in my case this is their membership number.

I would like to ensure:

  • User enters only numbers.
  • If their membership number is "1251" populate the field with leading zeros and put that into the database (eg: "001251";).



How do I do this?
admin Accepted Answer
Admin
Hi and sorry for late reply, we had a technical issue, so we have not received a ticket notification.

This is not possible with a field of type Number, you should use a field of type Text and a simple plugin that fills value with 0.

1) Configure Text field to accept only numbers
Configure options like screenshot, with a custom format like [0-9]{6} then it will accept only numbers (max 6 numbers)

2) Write the plugin to add zero to the number
- Download, Install and Enable Skeleton Plugin (you will find it at http://docs.easy-profile.com/index.php/article/triggers)
- Open file /plugins/jsn/skeleton/skeleton.php
- remove samples functions: triggerFieldAvatarUpdate, triggerProfileUpdate
- add function like this:
public function triggerProfileUpdate($user,&$data,$changed,$isNew){ 
if(!empty($data['alias_of_the_field'])) // remove this line if you allow empty value, so it will become like 000000
$data['alias_of_the_field'] = str_pad($data['alias_of_the_field'], 6, "0", STR_PAD_LEFT);
}
Attachments (1)
  1. more than a month ago
  2. General
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.