FixSometime Yesno element throw fatal error is acl protected

lcollong

FabriKant d'applications web
I use a yes/no element in a list used to store users's data together with the user plugin to have a register form and bypass the joomla's one.
This yes/no elt contains the "blocked" equivalent to the juser field.
It is acl protected to not appear in the form/detail view but only in the list view with icon replacement.
There is a default value ("0" in the default field and button set to "default to no").
I get error 500 "sometime".

I'have been able to reproduce the problem with a 4 columns test (id, date_time, field and yes/no).
If the yes/no element is set to default public on all acl, everything works.
If you set the yes/no element to "special" on all except list view, the element does not show in the form view but still in the list as expected. If you try to add a new row, you'll get :

Code:
500
Store row failed: INSERT INTO `f_test` ( `date_time`,`nom`,`yesno` ) VALUES ( '2023-05-22 07:07:11','nom3','' ) Incorrect integer value: '' for column 'yesno' at row 1 ; Please inform your web-site owner
Une erreur est survenue pendant l'exécution de la requête.

Il est possible que vous ne puissiez visiter cette page en raison de :

[LIST]
[*]un lien/favori obsolète
[*]une adresse erronée
[*]un moteur de recherche possède un listing périmé pour ce site
[*]vous n'avez pas accès à cette page
[/LIST]
500 Store row failed: INSERT INTO `f_test` ( `date_time`,`nom`,`yesno` ) VALUES ( '2023-05-22 07:07:11','nom3','' ) Incorrect integer value: '' for column 'yesno' at row 1 ; Please inform your web-site owner
/home/bishlws/examulmtest/components/com_fabrik/models/list.php:7928
Aller à la page d'accueil Page d'accueil
Call stack
# Function Location
1 () JROOT/components/com_fabrik/models/list.php:7928
2 FabrikFEModelList->storeRow() JROOT/components/com_fabrik/models/form.php:1992
3 FabrikFEModelForm->submitToDatabase() JROOT/components/com_fabrik/models/form.php:1924
4 FabrikFEModelForm->processToDB() JROOT/components/com_fabrik/models/form.php:1294
5 FabrikFEModelForm->process() JROOT/components/com_fabrik/controllers/form.php:322
6 FabrikControllerForm->process() JROOT/libraries/src/MVC/Controller/BaseController.php:678
7 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_fabrik/fabrik.php:200
8 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
9 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
10 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
12 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
13 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
14 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
15 require_once() JROOT/index.php:32

The default value is wrong. Should be '0' instead of '' (or null).

Is this something already "under investigation" or should I try to find a fix ?

NB : I did the same test on a J3/F3/Php 7 site without any problems.
 
Last edited:
or should I try to find a fix ?
Yes please.
I assume it's the in the meantime well known php8 ''!=0 :rolleyes:

At a quick glance:
Maybe
field 'default' needs 0 in fields.xml
and/or in yesno.php there are several defaults comparing/setting to ''
 
I spent a couple of hours without success.
As a workaround I prevent the value to be empty in the parent getValue (radiobutton.php) function

Code:
    public function getValue($data, $repeatCounter = 0, $opts = array())
    {
      
        $v = parent::getValue($data, $repeatCounter, $opts);
        // $$$ rob see http://fabrikar.com/forums/showthread.php?t=25965
        if (is_array($v) && count($v) == 1)
        {
            $v = $v[0];
        }
        if ($v === '') $v = '0';  // added to prevent yesno element to fail store row in case ACL does not show it on the form (value empty instead of default).
        return $v;
    }

But it should disturb in some radiobuttons real element default value. So it's not a solution.

I wasn't able to find where the formModel's data is initially built and why it is not using the raw value (correctly set) rather than the rendered one (set to '' instead of JYES/JNO)...

Added : wrong Hack. It modifies radiobutton default value. Not usable.
 
Last edited:
There is a default value ("0" in the default field and button set to "default to no").
Is the error gone if you don't set anything in the default field?

I'm trying to understand what public function getDefaultValue($data = array()) is doing at all with arrays here.
 
Actually no. In my particular setup where this element is not editable in the form view, whatever I set as default value, it shows the image of 'no' (icon). So it seems to never load the default value on form build or on form submit.
My icons are inverted (red cross for 1 and green action-check for 0) as they initialy stand for "user is blocked". So I want red cross if the user is blocked (1).
Whatever I set as default value it shows the green action-check (0).
I've used the button default yes/no (see screenshot) with the same value as the default field. Tested with both to 0 and both to 1.
I've used the button default yes/no with nothing in the default field. Tested with Yes and with No
I've used the button default yes/no with eval swith on and "return TRUE;" or "return FALSE" according to the button default switch.

And each time I save the form I get the error 500 due to insert '' on a int(1) column.

Analysing fabrik's internal structure shows that the non raw value of the element is set to something but the raw value is always empty.

Hope you'll understand better than me where the default value is being screwed up before record is inserted.
 

Attachments

  • Capture.PNG
    Capture.PNG
    16.2 KB · Views: 205
  • Capture.PNG
    Capture.PNG
    12.5 KB · Views: 212
  • Capture.PNG
    Capture.PNG
    5.4 KB · Views: 202
  • Capture.PNG
    Capture.PNG
    30.2 KB · Views: 215
Hi @lcollong
Not sure if you still have this issue but I had the exact same issue on Yes/No elements.
I had two elements one called 'approved' and 'mark_paid'.
The problem was with Inline javascript code on the element.
When i removed it the error went away.
I didnt work out why the error
500
Store row failed: INSERT INTO
was failing on both approved / mark_paid elements however although i think it was the disabled=true bit preventing any value from being inserted

The js being used was
approved Yes/No
JavaScript:
var uidClaim = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___userid').getValue();
var uidCur = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___curid').getValue();

if(uidClaim == uidCur) {
  document.getElementById("adtldldd_claim___approved0").disabled = true;
  document.getElementById("adtldldd_claim___approved1").disabled = true;
}

mark_paid Yes/No
JavaScript:
var uidClaim = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___userid').getValue();
var uidCur = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___curid').getValue();

if(uidClaim == uidCur) {
  document.getElementById("adtldldd_claim___mark_paid0").disabled = true;
  document.getElementById("adtldldd_claim___mark_paid1").disabled = true;
}

Hope this helps anyone with similar error
 
Hi @ontarget ,

Actually, we made it totally differently with the customer. Hence no more need to repair it.
But thanks a lot for explainning this here as it will probably appear sometime somewhere again.
 
FYI i tried to force the element value even if disabled using a further conditional but the console.log always showed a blank value so I gave up as well!!

Code:
if (document.getElementById("adtldldd_claim___approved0").disabled) {
        Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___approved').setValue(0);
    }
} else {
    Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___approved').setValue(1);
}

Despite this value was nothing not even null or 0 just emptiness!
 
Coming back to this (because of https://fabrikar.com/forums/index.php?threads/store-row-failed-incorrect-integer-value-for-column-view_level-at-row-1.55029/#post-288757
where the default is missing)

I can't replicate with your settings.
This yes/no elt contains the "blocked" equivalent to the juser field.
...
I'have been able to reproduce the problem with a 4 columns test (id, date_time, field and yes/no).

Is this with jUser plugin added?
Or a simple form without plugin with only these elements?
 
Can't remember. It's pretty old and I had never faced back again this problem.
The purpose of the initial form was to create a dedicated registring form to create an account with additionnal data and process. So, yes, the form had the jUser plugin set to create/delete the corresponding users in Joomla. The idea was to see wich users might be blocked (filtering) in the list view without being able to modify this in the form view.
But for the small test itself with the 4 fields I'm speaking about, I'm not sure the jUser plugin was present and published or not. Sorry, but I do not have time to do the test again in the coming days.
 

Members online

No members online now.
Back
Top