TOPIC:

Field only editable for admin 7 years 7 months ago #114149

  • Topic Author
  • simun
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 106
  • Thanks: 0
@ lennerd.
The code framework I've written into the initscript of the hidden element is this:
if(element.value != '4'){
ff_getElementByName('Final_conclusion_from_the_management').disabled = true;
}
if(element.value != '4'){
ff_getElementByName('Finished').disabled = true;
}
'4' is the ID-number of the administrator group I want only to be allowed to edit this field, while all others are set on read only.
I suppose this code framework is correct?

And then I am supposed to copy this code:
jimport( 'joomla.access.access' );
$this->execPieceByName('ff_InitLib');

$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id, false);
ff_setValue('groupid', $groups[0]);
Chris said into the Before form piece (don't know which one though) and you say after the switch statement. Don't really know what you mean about the switch statement.

I think I can say I'm a little confused.

Please Log in or Create an account to join the conversation.

Field only editable for admin 7 years 7 months ago #114254

  • lennerd
  • Offline
  • Developer
  • Developer
  • Posts: 4669
  • Karma: 72
  • Thanks: 411
Hello,

sorry for this. Please try the following steps:

@simun:

Chris provided two snippets of code. One for a before form piece and one for an initscript.

1. go to Form properties->advanced->more options-> form pieces-> before form-> custom and copy the following into the box:
jimport( 'joomla.access.access' );
$this->execPieceByName('ff_InitLib');

$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id, false);
ff_setValue('groupid', $groups[0]);

2. go to the element with the name groupid -> initscript -> custom->click page entry and click "create code framework" then it will show this:
function ff_groupid_init(element, condition)
{
    switch (condition) {
        case 'pageentry':
            break;
        default:;
    } // switch
} // ff_mytext_init

3. after case 'pageentry: copy chris' code so that in the end it should look like this:
function ff_groupid_init(element, condition)
{
    switch (condition) {
        case 'pageentry':
if(element.value != '4'){
ff_getElementByName('Final_conclusion_from_the_management').disabled = true;
}
if(element.value != '4'){
ff_getElementByName('Finished').disabled = true;
}
            break;
        default:;
    } // switch
} // ff_mytext_init

4. save properties-> save form -> and test the form

@tokao

enable the elements in the breezingforms again (elements got disabled/enabled through contentbuilder)

Your scenario will look like this:

1. one Breezingforms form with all elements enabled
2. two views one public and one admin view

3. in the public view go to the editable column and enable all elements you want the public to fill
4. in the admin view only enable the additional fields and disable the rest
Regards,
Stefan

===============================================
Satisfied? Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
===============================================

Please Log in or Create an account to join the conversation.

Field only editable for admin 7 years 7 months ago #114270

  • Topic Author
  • simun
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 106
  • Thanks: 0
Hi lennerd

Thanks for a detailed explanation.

I followed your instruction step by step.
Sorry, but when I tested logging inn just as a registered user and entered my ContentBuilder menu and pressed 'New' or 'Edit' for an existing post, I was still allowed to fill out those two fields in the form. (Which I as a registered user shouldn't be, but only to read it. Only if I've logged inn as an Editor ' ID: 4' or superuser 'group ID: 8' should I be able to edit)
I checked and double checked to see if I missed a step or a code sentance, but couldn't find anything missing.

Please Log in or Create an account to join the conversation.

Field only editable for admin 7 years 7 months ago #114452

  • lennerd
  • Offline
  • Developer
  • Developer
  • Posts: 4669
  • Karma: 72
  • Thanks: 411
Hello simun,

please try the following code as initscript:

 JQuery("[name=\"ff_nm_final[]\"]").attr("disabled", true);
function ff_groupid_init(element, condition)
{
    switch (condition) {
        case 'pageentry':
if(element.value != '4'){
JQuery("[name=\"ff_nm_Final_conclusion_from_the_management[]\"]").attr("disabled", true);

}
if(element.value != '4'){
JQuery("[name=\"ff_nm_Finished[]\"]").attr("disabled", true);

}
            break;
        default:;
    } // switch
} // ff_mytext_init

And please make sure that

Final_conclusion_from_the_management

and

Finished

are the real names of the element and not the labels.

I hope this helps.
Regards,
Stefan

===============================================
Satisfied? Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
===============================================

Please Log in or Create an account to join the conversation.

Field only editable for admin 7 years 7 months ago #114469

  • Topic Author
  • simun
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 106
  • Thanks: 0
Hi lennerd

tried copying your code into the initscript of the 'groupid' hidden element, but doesn't seem to have any effect.
Final_conclusion_from_the_management and Finished are the names of the elements.

Please Log in or Create an account to join the conversation.

Field only editable for admin 7 years 7 months ago #114508

  • lennerd
  • Offline
  • Developer
  • Developer
  • Posts: 4669
  • Karma: 72
  • Thanks: 411
Hello Simun,

thats odd, I tested this code and it is working on my side.

Might it be possible to see and test this on your site?
Regards,
Stefan

===============================================
Satisfied? Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
===============================================

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!