juser form plugin condition - password always required

Hi All!

I'd like to use juser form plugin condition option. I have a yesno element in the form. If it is set to Yes the condition return true, if set to No the condition return false to prevent the juser plugin from running.

The problem is my password element is always requiring some value, also if the condition returns false.
I haven't any added validation to password element.
Any suggestion?
 
Hi troester!

Yes I know there is a built in not empy validation. But there is no way to avoid this when juser plugin condition return false?
 
Hmmmm.

Interesting, I'll take a look. Not sure why this has never been flagged as an issue before, seems like it would be a common issue.

-- hugh
 
Ah, do you have J! validation rules enabled on password?

Looks like we already have some code to allow empty when editing:

https://github.com/Fabrik/fabrik/blob/master/plugins/fabrik_element/password/password.php#L235

... so it checks to see if there's a rowid, and only enforces "not empty" if there isn't a rowid (ie. this is a new form, not editing).

So I suspect the problem is that we do the J! validation check before that ...

https://github.com/Fabrik/fabrik/blob/master/plugins/fabrik_element/password/password.php#L212

Can you confirm that a) you have J! validation enabled, and b) if you disable that, it works?

If this is indeed the issue, I think it's easily fixed.

-- hugh
 
Hi hugh,

thanks for yout interest.

NO it's not enabled, J! validation is disabled in the password element setting.

My use case:

I have a form to record employee. But not all employee get access to the application so when you create employee you can disable juser plugin with a yesno element.
 
Hmm, it should still detect that you are editing a row, and not test for empty.

Are you loading the form through a menu item with usekey/rowid=-1 set?

-- hugh
 
I think there is a misunderstanding between us. Users with administrative privilages can create other users (employee) but not always with associated Joomla user.

What I want to achieve: I create a new employee with my fabrk form but I don't want to create associated Joomla user because this employee won't have access to login in the application. So I select no with yesno element and don't add password then submit the form. The juser plugin condition returns false (because I selected no with yesno element). Now the user (employee) is created in my fabrik list without associated Joomla user. If later I open this record for edit and select yes with the yesno element (because my employee now should have access to login) and add password then submit the record, a new associated Joomla user must created.

My problem is that I can't submit the form without password even the juser plugin condition return false.
 
OK, so does it fail when editing, or only when submitting a new form (with the juser condition as false), or both?

The way the code looks, it should allow you to edit an existing record, and submit with an empty password. But it won't let you submit a new form with an empty password.

-- hugh
 
I may just have to add an "Allow Empty" option to the password empty, with the choices being "New / Edit / Both", and leave it up to the admin what they want. Tweak it so we don't call the J! validation if allow empty applies to that submit and it's empty.

I think then you could turn the built in empty check off on the password element, and add a 'notempty' validation to it, with the same condition as the juser. So 'notempty' only runs if you are calling juser. And if the form is new, I guess.

Code:
return $formModel->getElementData('yourtable___yesno', true) === '1' && $formModel->isNewRecord();

... would then only check for empty if your yesno is Yes, and it's a new record.

-- hugh
 
You are absolutely right :) You are my man. It sounds well. Thanks in advance.

When this update will be available for the password element?
 
Usually I don't add features for Community threads, but as our sub system is offline pending a restructuring, I'll go ahead and do it in the next day or so.

-- hugh
 
Yes, I know it's not included in free support. As soon as your subscription subpage will be working again I will subscibe. Please let me know. Thx for help.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top