October CMS - required checkbox
How could I validate if the checkbox is ticked?
public $rules = [ 'name' => 'required', 'email' => 'required|email', 'phone' => 'required', 'terms' => 'required', ];
'terms' is the name of the checkbox. Now I get the alert about required field even if it is checked.
<input type="checkbox" name="terms" value="1" id="terms"/>
Simple HTML5 attribute required is also not working.
Wouter Van Damme has it right. You simply need to use the trait listed in that documentation. like so:
public $rules = [ 'name' => 'required', 'email' => 'required|email', 'phone' => 'required', 'terms' => 'required|accepted', ];
here is an october specific link although the answers are the same.http://octobercms.com/docs/services/validation#rule-accepted
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms