populate yesno element

cap

Member
i am trying to use the yesno element for automaitic populatin gits value
so i need to use an expression to set the value for it (yes or no), with an expression that check radiobutton element with s/n answer
so i am using this
if ('{lista___artBTN}'=='N')
{return 'no'';}
in the yesno element..but seems to do not work
does this element accept this kind of expression to populate its value?
 
You probably want to return a value, Yes/No stores as zero or one, so return zero in this case. You should probably also have an else which returns 1.
 
You probably want to return a value, Yes/No stores as zero or one, so return zero in this case. You should probably also have an else which returns 1.
But it isalways on No, whateverni di did ito, may be the syntaxnis not correct?the element does it support this?
 
if i do the opposite
if ('{lista___artBTN}'=='S')
return 1;
the yesno remain on no
seems just not cahnging with these expresson at least

i am using this code in thae are called "default
thre is in another page another default value to set, a dropodown menu, with yes and no. If i set YeS on tihs dropdown, the default value of the yesno is still No
may be there is some confusion with this element?
 
Last edited:
i have find out that for record that already there..nothing happen
for new record i get error
Store row failed: Incorrect integer value: '' for column `longactingptvorg_longacting`.`lista`.`Completo` at row 1 ; Please inform your web-site owner
so where is th eproblem wrong expression or what?
 
"Default" field sets the element's value only when adding new record. To change the yesno element's value depending on another element you need to add custom javascript to that other element (onchange or click event depending on element type).
 
Ok, clear, and what s wrong with the code i have posted?
also... If i use the predefined action for php i don t have the possibility the check other elements.
With code can i do?
The problem is that i don t know to write that code :(
 
And anyway...for what i understand the php run when an actuon is made in that element.but if the element that give the value to yesno, is another one....how does it work?
 
You cannot run PHP-code in the element Javascript section, those are totally different programming languages (js for front-end and PHP for back-end).

You need to do it like this for example. In your radiobutton element add element javascript on "click" event and custom code like:
JavaScript:
var my_radio_value = this.get('value');

if(my_radio_value == "X") {
  jQuery("#tablename___yesno-element-name").find('.fabrikgrid_0').trigger('click');
} else {
  jQuery("#tablename___yesno-element-name").find('.fabrikgrid_1').trigger('click');
}

This code gets the value of your clicked radiobutton element and then triggers click in yesno element's "yes" or "no" option. There are also alternatives how to do it like setting the yesno element's value via jQuery/js and removing / adding the "Active" class etc.

Basically, this code is just jQuery and not Fabrik specific, so you can find a lot of info on the internet (stackoverflow) or use Chat GPT. For example you just need to search for "How to set bootstrap radio button group value programmatically with jQuery" etc, etc.

And of course do not forget to change "X" and element id in the code to match yours.
 
Last edited:
ok thanks..before i try to understand properly and adjust to my need one question
this is for onclick
But on click don't save the value of yesno, cause everytime need to be clicked to get again that value
So that condition should be checked on load for example (i think) so that in the list i can see the proper value of the yesno element
this is wht i have understood from doing some test with predefined actions, at least
am i wrong?
 
After you save the form, yesno element's value will be saved to database in the state it is before the user clicks on form "Save" button. So you do not need to set the value again when editing the record.
 
Last edited:
  • Like
Reactions: cap
ok
i have used this code
replacing the element name selecting the onclick action

var rbutton = this.get('value');

if(rbutton == "*") {
jQuery("#lista___Completo").find('.fabrikgrid_1').trigger('click');
} else {
jQuery("#lista___Completo").find('.fabrikgrid_0').trigger('click');
}

where lista___Completo is my yesno element

nothing happen
where do i make mistake?
 
I have a working solution with form plugin, but if you don t mind i d like also to see why this don t work!
 
Hard to say as it's working here. You can try adding debugging in your code like:
Code:
var rbutton = this.get('value');

console.log("rbutton  value: "+rbutton );

if(rbutton == "*") {
console.log("value is *");
jQuery("#lista___Completo").find('.fabrikgrid_1').trigger('click');
} else {
console.log("value is not *");
jQuery("#lista___Completo").find('.fabrikgrid_0').trigger('click');
}

and see what it displays in browser console when you change your radiobutton value.
 
in console seems fine
it says rbutton value: E or NE or * according to what i click
and then value is * or value is not *
accordingly
 
Then it has to be the "jQuery("#lista___Completo").find..." part. Maybe your html structure is a bit different. So check with the browser inspect tool that the id of the yesno div container is correct and it has a children with classes "fabrikgrid_0" and "fabrikgrid_1".
 
Can you upload a screenshot here from the browser inspector containing the yesno element's HTML.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top