Hello!
I have found that little bug this morning.
Seems that there were some topic talking about this, but a little bit old and according to Max, solved.
So here I am :
On Load event
Custom code
Show Html
Preview
Radio box
Label Text : Radio box
Field Name : rb_1
Field Default Value : {choix}
Options :
0=non
1=oui
2=peut-être
Check box group
Label Text : Check box
Field Name : cb_1
Field Default Value : {choix}
Options :
0=non
1=oui
2=peut-être
When I test the form, the radio box value checked by default is 0 (for "non") and idem for the check box group.
However, if I set "Field Default Value : 2", it's working, but I need the default value match with some data loaded (for a more complicated form).
Any help would be appreciable.
Thanks
Florence
I have found that little bug this morning.
Seems that there were some topic talking about this, but a little bit old and according to Max, solved.
So here I am :
On Load event
Custom code
<?php
$form->data['choix']=2;
?>
Show Html
Preview
Radio box
Label Text : Radio box
Field Name : rb_1
Field Default Value : {choix}
Options :
0=non
1=oui
2=peut-être
Check box group
Label Text : Check box
Field Name : cb_1
Field Default Value : {choix}
Options :
0=non
1=oui
2=peut-être
When I test the form, the radio box value checked by default is 0 (for "non") and idem for the check box group.
However, if I set "Field Default Value : 2", it's working, but I need the default value match with some data loaded (for a more complicated form).
Any help would be appreciable.
Thanks
Florence
Hi Flob,
As far as I know you can't use curly brackets in the Field Default Value box.
If you want the default value to be 2 then use 2
If you want to set a dynamic value (not strictly a default) then use code like this:
Bob
As far as I know you can't use curly brackets in the Field Default Value box.
If you want the default value to be 2 then use 2
If you want to set a dynamic value (not strictly a default) then use code like this:
<?php
if ( !isset($form->data['rb_1']) && !$form->data['rb_1'] ) {
$form->data['rb_1'] = 2;
}
?>
This will set a value if there isn't already one set in the $form->data array.Bob
Hi Bob,
Thanks for the quick reply.
I was suprised wthat we can't use curly brackets in the field default value box, because it's actually working for the text box and the text area.
That's why I was thinking this should work for the radio box and check box group.
Florence
Thanks for the quick reply.
I was suprised wthat we can't use curly brackets in the field default value box, because it's actually working for the text box and the text area.
That's why I was thinking this should work for the radio box and check box group.
Florence
Hi Florence,
I didn't even know that it worked in the text box and text area . . . you learn something every day.
Bob
Later: I looked at the code and I think I can see what is happening. It's not officially set up to work like that - but it does. With the text and textarea elements if you set the default value to {input_name} then the HTML is created with e.g.
But for the box and drop-down elements the value setting is like checked='checked' and the {input_name} default doesn't match any values so won't be set.
I didn't even know that it worked in the text box and text area . . . you learn something every day.
Bob
Later: I looked at the code and I think I can see what is happening. It's not officially set up to work like that - but it does. With the text and textarea elements if you set the default value to {input_name} then the HTML is created with e.g.
<input name='input_name' . . . value='{input_name}' />
then later the Republisher looks for all those curly bracket elements and replaces them with the value.But for the box and drop-down elements the value setting is like checked='checked' and the {input_name} default doesn't match any values so won't be set.
This topic is locked and no more replies can be posted.