1. cpaschen
  2. General
  3. Saturday, June 04 2016, 04:29 AM
I've been using EasyProfile for a while and love it.

I have an application that needs to have check-box style input, but the options to check need to come from an existing DB table.

In addition, I need to limit the number of check-boxes that can be checked to 3.

Is there any way to do this within EasyProfile?

If not, how would I go about creating a new element type that I could use in EasyProfile?

Or (less desired option, but possibly workable) ... with the SelectList is there any way to limit the 'Multiple selection'?
So the user can only select 3 options from the list?

(I'm pretty proficient with PHP and just barely with js - so I'm OK if this requires some coding - as long as it won't get broken on future EasyProfile updates)
admin Accepted Answer
Admin
Hi,

I have an application that needs to have check-box style input, but the options to check need to come from an existing DB table.

sorry this is not possible.

In addition, I need to limit the number of check-boxes that can be checked to 3.
You can do this with Javascript.

If not, how would I go about creating a new element type that I could use in EasyProfile?
This is possible but very very complex, to create new field type you need to create a new file into folder /administrator/com_jsn/helpers/fields/typename.php based on some existing file. Basically in this file there are functions to:
- create/delete column in DB to store data
- Search features
- XML declaration for Forms
in XML declaration you need to specify field type, this field type can be a Joomla built in field type or a custom field type, if you use a custom field type you need to create model for this (this like all Joomla fields)
Easy Profile field type models are into /administrator/com_jsn/models/fields/, all these models inherit some Joomla pre-existing field model (I understand that is not clear, but there is no way to explain this in a few words)
Some Easy Profile not need a custom model because it inherit directly Joomla field type model (normally stored in /libraries/joomla/form/fields/)
You need also to create a rule for server side validation (also this come from Joomla API), we have some custom rule in folder /administrator/com_jsn/models/rule

This require many Joomla dev knowledge, not only PHP, so the most simplest way is to edit already existing fields

Or (less desired option, but possibly workable) ... with the SelectList is there any way to limit the 'Multiple selection'?
Also this require many many work, because the field type inherited by Joomla not have this feature.

I recommend you this way (to not change Easy Profile core files)
- limit the number of check-boxes with Javascript
- make a script to change options in DB, options are stored with all others parameters into table "#__jsn_fields" in column "params". Parameters are stored in JSON format so
- Load JSON string
- Transform it in array or object with json_decode function
- Change Options into array/object
- Transform in JSON string with json_encode function
- Update DB
  1. more than a month ago
  2. General
  3. # 1
cpaschen Accepted Answer
thanks!
  1. more than a month ago
  2. General
  3. # 2
  • Page :
  • 1


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