I have an object field that is of number data type, based on a picklist value in the parent object field I want to render in the visual force page as an input check box. If the check box is checked true, I want the value saved to 1 and 0 if false. If the picklist value requires it to render as a text field and I want to save the value as a number field. I'm successful in rendering the field as inputcheckbox and inputfield, but its not saving the checkbox value to the field. It is saving the value if it is rendered as a text box.
<apex:datatable value="{!attendanceRows}" var="o" id="theTable"
<apex:inputField value="{!o[column01.FieldName]}" rendered="{!IF(c.Type__c='High School',true,false) }"/>
<apex:inputCheckbox value="{!o[column01.FieldName]}" rendered="{!IF(c.Type__c='Middle School',true,false) }"/>
In my controller I'm doing an upsert to the object.
public List<School__c> attendanceRows { get; set; }
public void SaveAttendance() {
try {
if (attendanceRows.size() > 0) {
upsert attendanceRows;
}
}
catch(DmlException e) {
System.debug('An unexpected error has occurred while saving to Beneficiary_Attendance_Detail__cSchool__c: ' + e.getMessage());
}
}
// Header Definition Class
public with sharing class HeaderDefinition
{
public HeaderDefinition(Boolean pIsVisible, String pColumnName, String pFieldName)
{
isVisible = pIsVisible;
ColumnName = pColumnName;
FieldName = pFieldName;
}
public Boolean isVisible { get; set; }
public String ColumnName { get; set; }
public String FieldName { get; set; }
public string outString()
{
return FieldName + ' :: ' + ColumnName + ' - ' + String.valueOf(isVisible);
}
}
SaveAttendance();
How do I save/get the value of the inputcheckbox?