Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:23:29+00:00 2026-06-13T12:23:29+00:00

Using SilverStripe 2.4.7. I’ve done some searching but I can’t seem to be able

  • 0

Using SilverStripe 2.4.7.

I’ve done some searching but I can’t seem to be able to find an answer to this. I want to include a checkbox on a popup window in dataobjectmanager but not for every user.

I have two separate pages, one for one user and another for the other, and I only want the checkbox on one. I thought an if statement would suffice, quick and simple right?

public function getCMSFields()
{
    $categories = array("Morning","Afternoon", "Evening", "Night");

    return new FieldSet(
        new TextField('Title'),
        new DatePickerField('Date', 'Date'),
        new ImageField('Photo', 'Photo'),
        new MoneyField('AdultPrice', 'Adult Price'),
        new MoneyField('ChildPrice', 'Child Price'),
        new DropdownField('Category', 'Choose a Category', $categories)
    );

This is my attempt at the if statement approach

        if($this->ClassName == 'Movie'){
        $films= DataObject::get('Films');

        if (!empty($films)) {

        // create an array('ID'=>'Name')
        $map = $films->toDropdownMap('ID', 'Name');

        $fieldset->push(new CheckboxSetField(
            $name = "Films",
            $title = "Select Films",
            $source = $map
            ));
        }
    }

Basically this works if I use it within getCMSFields_forPopup, but not in just getCMSFields, but changes my checkboxsetfield to a dropdown.

Edit

I have found that my approach would not work due to the fact that the DOM Popup cannot have the classname of the page which contains the DOM (DataObjectManager). This is a simple inheritance issue and I can’t believe I didn’t see it before. See the answer below for details of how I solved my original query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:23:30+00:00Added an answer on June 13, 2026 at 12:23 pm

    In the end the answer was quite simple. I did the following and I hope someone finds this useful.

    Create the checkboxset on the page as normal

    if(Permission::check("ADMIN")){
            if (! empty($values)) 
            {
                $checkBox = new CheckboxSetField(                                           
                    $name = "Values",
                    $title = "Select Value",
                    $source =  $values
                );
                $fieldset->push($checkBox);
            }
        }
    

    The if statement with Permission::check(“ADMIN”) checks if the admin is logged in and only shows the checkboxset if they are.

    You will also need to include the $fieldset->push within this method to add it to the cms. The ADMIN can be changed to any of your user groups which you created in the security panel so this is an adaptable approach.

    I found this the best way for me but if someone can improve on it/offer a better solution I’d love to hear about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing some web applications using Silverstripe and want to use a recent
I'm using 2.4.7 and I want to include some validation for two fields which
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using range() in Underscore I can make something like this: _.range(10); >> [0, 1,
Using HTML 5, I want to play multiple sounds simultaneously. how can I do
Using Rails 3, but I guess doesn't matter. I put this in the template
Using C#, I want to show the image in the Access column but failed
I'm using SilverStripe 3.0 CMS, and I need to include a Google Map into
I'm using SilverStripe 2.4.7 and I want to add a method that parses the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.