0

I want to have a CheckboxField to select if social icons should be shown in the website footer or not. My idea is to have a main CheckboxField to disable all of the icons and individual ones that are only enabled if the general one is checked. Otherwise they should be greyed out.

I thought about something like this (does not work).

CompositeField::create(

    CheckboxField::create('ShowSozialIcons', 'Sozial Icons anzeigen'),

    CheckboxField::create('ShowYoutubeIcon', 'Youtube Icon anzeigen')->setDisabled($this->ShowSozialIcons),
    CheckboxField::create('ShowFacebookIcon', 'Facebook Icon anzeigen')->setDisabled($this->ShowSozialIcons),
    CheckboxField::create('ShowInstagramIcon', 'Instagram Icon anzeigen')->setDisabled($this->ShowSozialIcons),
    CheckboxField::create('ShowTwitterIcon', 'Twitter Icon anzeigen')->setDisabled($this->ShowSozialIcons),
    CheckboxField::create('ShowLinkedinIcon', 'Linkedin Icon anzeigen')->setDisabled($this->ShowSozialIcons),

)->SetTitle('Anzuzeigende Elemente'),
  • What about this doesn't work? Are they not being set as disabled? Or are you unsure how to enable them when the main checkbox is enabled? Please provide more details. One thing that stands out is that you seem to be setting them as disabled only if the checkbox _is_ checked here, which seems like the opposite of what you described as your desired outcome. You'll probably also want some javascript in there so users don't have to save the form after checking the first box before they can check other boxes. – Guy Sartorelli Oct 16 '22 at 20:12

0 Answers0