London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

[Required] Checkbox issue

Vote:
 

Hello! I want a checkbox to show up instantly when creating a page. To do this with other types I just add the [Required] attribute to the property. However, it works differently with checkboxes, because for it to be treated as specified it needs to be set to true. If I put required on it it will show up but if I don't check it (as in set it to true) I can't create the page.

Is there any other way I can make it show on page creation not using [Required]?

[Display(
            Name = "Visa bild publikt",
            Description = "Om denna är ikryssad så visas bilden även om man inte är inloggad",
            GroupName = SystemTabNames.Content,
            Order = 600
        )]
        [CultureSpecific]
        [Required]
        public virtual bool ShowImagePublic { get; set; }
#140960
Nov 05, 2015 8:23
Vote:
 

Not sure if this works, but what if you create an image block with this property and the image, and set the block property to required?

#140962
Nov 05, 2015 9:42
Vote:
 

I'd say it's a flaw in the design, aka a bug.

#140978
Nov 05, 2015 14:16
Vote:
 

Btw, we've solved similar situations earlier with using a select with Not set/True/False instead of having a checkbox.

#140979
Nov 05, 2015 14:18
Vote:
 

It would be nice if it worked to use a checkbox but apparently it doesn't, for now using a select with values yes, and no will suffice.

Thanks for the help!

#140988
Nov 05, 2015 15:37
Vote:
 

Hi,

I prepared blog post about how you could solve it. Here is the link.

The source code is available on gist.

#141036
Nov 06, 2015 19:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.