'disable element' option delete data

Fred04

Member
Hello,
I tried the option 'disable element' in the 'field' plug-in.

It just does not work well because after saving the changes I did in my form on some other elements, the value for the element with the option 'disable' has just been deleted from the database (the value is now NULL in mySQL)

can you check that?
 
I can confirm this:
element is shown (readonly) in the form, after saving it's NULL
 
ok, I understand.

Actually here is what I want to do. I want to display an element. When the user save the form to post some changes on other elements I do not want to update the element I only 'display'. I agree that it should be the same value but if in the meantime someone else did a change on this element, the user will unwillingly update it back to the previous value.

So, is it possible in Fabrik to avoid posting a specific element so that it will never alter the current value in mySQL?
 
Well I think this must be related to your display element question, and I think that will basically do it for you.

You could do it with a custom template or with the calc element as well.
 
you're right. The benefit of the 'display' plug-in is that the element is not included in the 'post' method


however I can use the 'display' plug-in only when in have something human readable in my sql table. I mean if I just store a FK it does not apply. One workaround seems to create a view in mysql with all the info and then use the 'display' plug-in.

Would be good to have an option 'do not post' or to consider that when editable = no according to ACL setting then you do not post the element value. That would be the best :)
 
I mean if I just store a FK it does not apply

You mean because you only see a number?

Would be good to have an option 'do not post' or to consider that when editable = no according to ACL setting then you do not post the element value.

You could probably set this up as a form plugin, it would need some coding though.

You could probably do an ACL lookup on post and if the user isn't authorised it posts all data except that element.


Of course anything is possible because it's 'Fabrik' but some things do have to be coded where the options are not available. :)
 
You mean because you only see a number?
yes, exactly

ACL lookup on post and if the user isn't authorised it posts all data except that element
that would be great but my coding expertise is not at this level right now... even if I learnt a lot with Fabrik
 
Well for the first part you could always use a calc instead. I'm not sure at what point this field ever gets updated but I assume it does at some stage as per your earlier comment.

I agree that it should be the same value but if in the meantime someone else did a change on this element, the user will unwillingly update it back to the previous value.

If the element doesn't ever get updated from Fabrik or from a particular user you could always remove the element from the list so Fabrik doesn't touch it at all. Then a calc could return the value...


Code:
$db = JFactory::getDBO();
$id = '{checkboxcalc___id}'; // Your list id

$db->setQuery("SELECT carnames from repeatjoin1 rpt1 
INNER JOIN checkboxcalc calc 
on rpt1.id = calc.dbjoin WHERE calc.id = $id");

$result = $db->loadResult();


The above seems to work but obviously you would have to change it for your setup.
 
thanks for the code. I was also testing something similar. One more question, in my scenario I have 2 database connections. How do you select the right one?

$db = JFactory::getDBO();
can we put a connection ID somewhere?
 
I tried this

Code:
$cn = JModel::getInstance('connection', 'FabrikModel');
$cn->setId(2);
$db =& $cn->getDb(); 


$id = '{test2___idcomp}';
$db->setQuery("SELECT descr from company INNER JOIN test2 on company.id = test2.idcomp WHERE idcomp = id");
$result = $db->loadResult();
return $result;

but without success. I only got an empty web page

in debug mode, I can see at then end of the log:

element eval default:Company
$cn = JModel::getInstance('connection', 'FabrikModel'); $cn->setId(2); $db =& $cn->getDb(); $id = '1'; $db->setQuery("SELECT descr from company INNER JOIN test2 on company.id = test2.idcomp WHERE idcomp = id"); $result = $db->loadResult(); return $result
 
Ha, I've found it (I know there was a thread about connections in fabrik3)
In f3, you can use one of our helper functions to get the DB object for your additional connections, so ...

$db = FabrikWorker::getDbo(false, 2);
2 is the connectionID
http://fabrikar.com/forums/showpost.php?p=137910&postcount=8

And I agree: if an element is set to be disabled or not editable I would expect its content not to be touched (and not to be deleted:().
 
Ha ha SNAP!

And I agree: if an element is set to be disabled or not editable I would expect its content not to be touched (and not to be deleted:().

I think it would be my natural assumption that disabled means simply don't touch it.

Most things in Joomla which is unpublished or disabled simply means don't include it for anything.
 
ok, it works with the following code in the code section of the 'display' plug-in

Code:
$db = FabrikWorker::getDbo(false, 2);
$id = '{test2___idcomp}';
$db->setQuery("SELECT descr from company INNER JOIN test2 on company.id = test2.idcomp  WHERE idcomp = $id");
$result = $db->loadResult();
return $result;

but what a workaround just to 'protect' a databasejoin element from being posted !

There must be an easier way just to ignore an element in the POST method?

As many of you my assumption was the 'disable' would not touch the element but as Rob confirmed it replaces the current value by NULL. In addition, the option 'disable' is not available in all pug-in. So again the best according to me would be to ignore the element in the POST method if 'editable' is false according to ACL setting.

comments and ideas are welcome
 
The initial problem sounds like a bug to me:
we seem to agree that the content of an element which is not editable (because of access level settings, or being disabled...) should not be touched.

But at the moment there are several scenarios where the content is DELETED.
disable means exactly that no data will be posted and null saved.
see http://www.w3schools.com/tags/att_input_disabled.asp
Also see the hover text on the field label ;)

If you want the value to be submitted then set to read only instead
"null saved" at the moment is "NULL saved" but should be nothing saved (the hover text says "data NOT submitted with the form" and not "data overridden with NULL"
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top