+ Start a Discussion
Lexie XiaoLexie Xiao 

Cannot save checkbox value in VF page

Hi! I am very new to visualforce page. I am trying to nest a very simple VF page with checkboxes within the event detail page. However, I cannot save my checkbox values. Every time I hit save, it refreshes the page and then the checked boxes become unchecked again. I do not know why that happens. Could anybody please tell me why and how I can fix it? Thank you very much!
<apex:page standardController="Event">
    <apex:detail subject="{!event}" relatedList="false"/>
    <apex:form id="theForm">
        <apex:pageBlock title="Event Check List" id="thePageBlock" mode="detail">
            <apex:pageblockButtons >
                <apex:commandButton action="{!save}" value="Save" id="save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:message for="save"/>
            <apex:actionSupport event="onclick" reRender="theBlock" action="{!save}"/>
            <apex:pageBlockSection columns="2" >
                <apex:inputCheckbox id="repregis" label="Representatives registered" onselect="{!event}"/>
                <apex:inputCheckbox id="boothregis" label="Booth registered"/>
                <apex:inputCheckbox id="payment" label="Payment made"/>
                <apex:inputCheckbox id="hotel" label="Hotel booked, if applicabale"/>
                <apex:inputCheckbox id="litsent" label="Literature sent"/>
                <apex:inputCheckbox id="boothsent" label="Booth sent"/>
                <apex:inputCheckbox id="promosent" label="Promotional materials sent"/>
                <apex:inputCheckbox id="Misc" label="Miscellaneous stuffs sent"/>
                <apex:inputCheckbox id="furniture" label="Furniture ordered"/>
    <apex:relatedList list="Attachments"/>
Hi!  Each of your inputCheckbox components have an id and a label but aren't binded to a field on the Event.  For example, if your Hotel field was represented by the custom field HotelBooked__c, you would bind it like this:
<apex:inputCheckbox id="hotel" label="Hotel booked, if applicable" value="{!event.HotelBooked__c}"/>

Once they are bound to a field they will load the value from the database, and save the value to the database when the standard save action is invoked.

Rob Kemper - OpFocus
Lexie XiaoLexie Xiao
Hi, robdobby! Thank you for your reply. Is there anyway to keep the values without creating custom fields? Because we are using PE, we only have 20 custom fields in activities, which we pretty much used all of them already...