I am having trouble with a populating a radio button with a read value boolean from a database. Chronoforms 4.0.
Below is a snippet of code from the HTML code the form wizard set up.
All the labeling appears & all other data from the table is being populated. This is a ghost action to report a Yes/No value from a 0/1 value recorded in the database. It requires a business administrator to change the value, but a member may always see what has been recorded for themselves.
Interestingly, the 'checked="checked"' portion, while in the HTML code, is not even being delivered to the browser! (Safari, FireFox or Chrome!) We are of the mind that something is stripping it from the server before it is ever transmitted to the client's browser. (We clear cache with every attempt!)
We can successfully change the titles & labels in HTML of this form & it processes at the browser, so we know that we are writing to the form on the server.
All data is being fetched from a single table about a member & that fetch is working. This is the only radio button on the form & it will not display the information to a Yes or No populated radio button.
I have also checked that a Custom Code field is not negating any "veteran" information. I have also checked Radio Box configuration that the veteran Field Name, Field title & Field ID are spelled correctly with proper letter case. The field default value=No & the Options are Yes=Yes, No=No.
2 Programmers, 5 hours later & we are at the end of our own ideas.
Your ideas?
Okay, just found something! The Radio Box Options have the know the data return values from the database. Therefore, 0=No, 1=Yes will populate the appropriate radio button with the data fetched from the database.
Now to prohibit a Joomla! Registered user with the ability to change this value. Only our business administrators who have administration or (if we correct all our scripts, I would prefer them to have Manager privileges.)
Thanks in advance.
Roger
Below is a snippet of code from the HTML code the form wizard set up.
cfdiv_radio multiline_start" id="veteran_container_div" style=""><label for="veteran">U.S. Military Veteran</label><input type="hidden" name="veteran" value="No" alt="ghost" />
<div style="float:left; clear:none;"><input type="radio" name="veteran" id="veteran_0" title="Veteran" value="No" checked="checked" class="" />
<label for="veteran_0">No</label>
<input type="radio" name="veteran" id="veteran_1" title="Veteran" value="Yes" class="" />
<label for="veteran_1">Yes</label>
</div><div class="clear"></div><div id="error-message-veteran"></div>
All the labeling appears & all other data from the table is being populated. This is a ghost action to report a Yes/No value from a 0/1 value recorded in the database. It requires a business administrator to change the value, but a member may always see what has been recorded for themselves.
Interestingly, the 'checked="checked"' portion, while in the HTML code, is not even being delivered to the browser! (Safari, FireFox or Chrome!) We are of the mind that something is stripping it from the server before it is ever transmitted to the client's browser. (We clear cache with every attempt!)
We can successfully change the titles & labels in HTML of this form & it processes at the browser, so we know that we are writing to the form on the server.
All data is being fetched from a single table about a member & that fetch is working. This is the only radio button on the form & it will not display the information to a Yes or No populated radio button.
I have also checked that a Custom Code field is not negating any "veteran" information. I have also checked Radio Box configuration that the veteran Field Name, Field title & Field ID are spelled correctly with proper letter case. The field default value=No & the Options are Yes=Yes, No=No.
2 Programmers, 5 hours later & we are at the end of our own ideas.
Your ideas?
Okay, just found something! The Radio Box Options have the know the data return values from the database. Therefore, 0=No, 1=Yes will populate the appropriate radio button with the data fetched from the database.
Now to prohibit a Joomla! Registered user with the ability to change this value. Only our business administrators who have administration or (if we correct all our scripts, I would prefer them to have Manager privileges.)
Thanks in advance.
Roger
Hi RLaurel,
As you found - the values have to match. If you have 1 & 0 in the data but the form values are Yes and No they won't work as expected.
To make these editable only by admins there are two approaches; the slightly simpler but less secure one is to use JavaScript to set the inputs as readonly for non-admins; my preferred solution would probably be to use a Custom Element element in the form and set the read-only parameter there, or just show a text span something like this:
Bob
As you found - the values have to match. If you have 1 & 0 in the data but the form values are Yes and No they won't work as expected.
To make these editable only by admins there are two approaches; the slightly simpler but less secure one is to use JavaScript to set the inputs as readonly for non-admins; my preferred solution would probably be to use a Custom Element element in the form and set the read-only parameter there, or just show a text span something like this:
. . . cfdiv_radio multiline_start" id="veteran_container_div" style=""><label for="veteran">U.S. Military Veteran</label>
</div><div class="clear"></div><div id="error-message-veteran"></div>
<?php
$user =& JFactory::getUser();
$is_admin = . . .; // add code here to detect user groups
if ( $is_admin ) {
?>
<input type="hidden" name="veteran" value="No" alt="ghost" />
<div style="float:left; clear:none;"><input type="radio" name="veteran" id="veteran_0" title="Veteran" value="No" checked="checked" class="" />
<label for="veteran_0">No</label>
<input type="radio" name="veteran" id="veteran_1" title="Veteran" value="Yes" class="" />
<label for="veteran_1">Yes</label>
<?php
} else {
$veteran = 'No';
if ( $form->data['veteran'] == 'yes' ) {
$veteran = 'Yes';
}
echo "<span>{$veteran}</span>
<input type='hidden' name='veteran' value='' />";
}
?>
Bob
You are correct! I solved my own problem by just thinking a little more about it.
I am going to try both alternatives you have suggested. The first because I know nothing about JavaScript, the other because I want to use better methods.
I always want to know the second way to "skin a cat"! ;-) Poor kitty!
I now have a different problem as we migrate our website from Joomla! 1.5 & ChronoConnectivity was used in the past, but the script does not work they way we desire.
I will make a separate post because it is a different problem & would not contribute to this thread!
I am going to try both alternatives you have suggested. The first because I know nothing about JavaScript, the other because I want to use better methods.
I always want to know the second way to "skin a cat"! ;-) Poor kitty!
I now have a different problem as we migrate our website from Joomla! 1.5 & ChronoConnectivity was used in the past, but the script does not work they way we desire.
I will make a separate post because it is a different problem & would not contribute to this thread!
This topic is locked and no more replies can be posted.