function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Olivia FordeOlivia Forde 

Required fields on a child object

I have a VF page which has a section with fields from a child object - these fields are required but I can still save the page if these fields are not completed. How do I force users to fill the fields on a child object.
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi Olivia,

Are you using inputField tag ?
If so please set required attribute to true.

If you are using something else ,Please paste your code here.

 
Olivia FordeOlivia Forde
<apex:inputCheckbox label="CA" value="{!BusUnits['CA']}" >
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
try below.
<apex:inputCheckbox label="CA" value="{!BusUnits['CA']}"  required='true'>
sandeep sankhlasandeep sankhla
Hi Olivia,

use required = true


<apex:inputCheckbox label="CA" value="{!BusUnits['CA']}"  required = true>

Thanks
 
Olivia FordeOlivia Forde
OK but I have 30 of these checkboxes and I only require 1 to be checked Regards Olivia [cid:image006.jpg@01CD902E.8CD33640] [cid:image002.png@01D06248.31CCFF30] [EOY Finalist 2013] [10258-seal]
sandeep sankhlasandeep sankhla
Hi 
​then you can use selected = true to make it check and uncheck
Olivia FordeOlivia Forde
If the checkbox is selected a new section is rendered so I cannot have all 30 selected and require the use to unslect them
sandeep sankhlasandeep sankhla
Hey Olivia,

What exactly you need ? Can you elaborate more ?
Olivia FordeOlivia Forde
Hi I have a VF page that references 30 checkboxes in a PanelGroup in a Panel Grid – when they are checked they open up another section – I need to force users to check at least one of these check boxes before they can save the page. Regards Olivia [cid:image006.jpg@01CD902E.8CD33640] [cid:image002.png@01D06248.31CCFF30] [EOY Finalist 2013] [10258-seal]
sandeep sankhlasandeep sankhla
Hi

You can bind onclick event on the submit button..onclick of that button you can call javascript function and check if all any checkbox is checked then user can continue , if nothing is selected then show alert ...