Radiobutton hide/show choices depending on user access level

monkframes

Member
Hi there, I?m a fabrik newbie but I?m getting fantastic results thank you all.

I want to display diferent choices in a radiobutton element depending on the user access level, I mean:
Access level 1 - ACTIVE | END
Access level 2 - ACTIVE | CANCEL
Access level 3 - ACTIVE | END | CANCEL

I need to store in the database field the status od an event (1=active, 2=finished, 3=canceled), but just let certain users to choose between certain options depending on their access level.

Thanks in advance.
 
You have to use the "eval populate" in the "Advanced" tab of your radiobutton to populate the options according to the user connected.
If you are not to comfortable with PHP, another approach would be to use 3 forms (build the 1st one, then make 2 copies), each one accessible based on the ACL. In each form you set up the options as requested.
 
Thanks for your quick answer.

If I'm not wrong, if Iuse 3 forms or groups with the same radiobutton element, the radiobutton options must be the same, what I need is to display 2 or 3 different options ....

I'm not a PHP expert but I can read and modify it, if someone could please give me some tips of the PHP code for the advance tab that will be very useful for me.

Thanks again.
 
No, if you have three forms, you can set different options for the radiobutton (or other elements) in each form. You can have also three different intro/outro to your form if you need to explain the different choices.
The final user will only see one form (based on his access group) and all forms records data in the same database.
The way to do this is to create the first list/form, add all the elements/groups and when it is ready, you just copy this list twice. This will create a copy of the form/group/elements.
You then have just to edit (un-linked) the radioelement in each copy and change the options.
 
Sorry to bother you again, but I decided to try the "eval populate" option. I?m trying to follow the tip (PLG_ELEMENT_RADIO_POPULATE_DESC="PHP Code to create options, should return an array of JHTML select.options,<pre> e.g. return array(JHTML: :_('select.option', '1', 'one'));</pre>.") but it seems that with the numeric values (0, 1, 2) it does not work but with alfa characters yes:

$opts = array();
$opts[] = JHTML::_('select.option', '0', 'Activo' );
$opts[] = JHTML::_('select.option', '1', 'Finalizado' );
$opts[] = JHTML::_('select.option', '2', 'Cancelado' );

return $opts;

Any clues ?
 
Finally I did it, here is my code if it could help someone:

$db = FabrikWorker::getDbo(false, 2); // I don't use the default connection
$query= 'SELECT `joomla_user_type` FROM `usuarios` WHERE `joomla_user_id` = ' . JFactory::getUser()->id . ';'; // I have a table called "usuarios" and the juser form plugin to manage users
$db->setQuery($query);
$myGroup = $db->loadResult();

$puedenFinalizar = array(13, 14, 15); // Access levels allowed for the 2nd option
$puedenCancelar = array(12, 13, 15); // Access levels allowed for the 3rd option

$opts = array();
$opts[] = JHTML::_('select.option', 'A', 'Activo');

if (in_array($myGroup, $puedenFinalizar)) {
$opts[] = JHTML::_('select.option', 'F', 'Finalizado' );​
}
if (in_array($myGroup, $puedenCancelar)) {
$opts[] = JHTML::_('select.option', 'C', 'Cancelado');​
}

return $opts;

What I can't understand is why with 0, 1 and 2 instead of A, B and C it does not work ....

Thanks for your help.
 
I have a couple of questions: how can I set one option of the radiobutton as 'default' or 'active' and how can I change the CSS class of one option ???

By the way, I noticed that the problem I mentioned in my previous post was if you try to set the value '0' as the first element of the array $opts[] ....
 
I really like this eval populate feature, but I can't figure out how to get a default option selected once populated.

Did you find out how or can someone tell me how to set the default when using this
 
Finally I decided not to use the Eval Populate, because I founded another way (better for my purpose) to do the same but directly on the list, not in the form. I used the list PHP plugin to display different buttons depending on the access level that change the field "status".
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top