Version: current

# Class RequiredFields

Required Fields allows you to set which fields need to be present before submitting the form Submit an array of arguments or each field as a seperate argument. Validation is performed on a name by name basis.

  Object
  Validator
  RequiredFields

### Direct known subclasses

`CustomRequiredFields`, `Member_Validator`

Package: forms\validators
Located at sapphire/forms/RequiredFields.php

## Methods summary

`public` | # `__construct( )` Pass each field to be validated as a seperate argument to the constructor of this object. (an array of elements are ok) Pass each field to be validated as a seperate argument to the constructor of this object. (an array of elements are ok) #### Overrides `Object::__construct`
`public` | # `useLabels( mixed $flag )`
`public` | # `removeValidation( )` Clears all the validation from this object. Clears all the validation from this object.
`public` | # `debug( )` Debug helper Debug helper
`public` | # `javascript( )`
`public` | # `php( mixed $data )` Allows validation of fields via specification of a php function for validation which is executed after the form is submitted Allows validation of fields via specification of a php function for validation which is executed after the form is submitted
`public` | # `addRequiredField( mixed $field )` Add's a single required field to requiredfields stack Add's a single required field to requiredfields stack
`public` | # `removeRequiredField( mixed $field )`
`public` | # `appendRequiredFields( mixed $requiredFields )` allows you too add more required fields to this object after construction. allows you too add more required fields to this object after construction.
`public` | # `fieldIsRequired( mixed $fieldName )` Returns true if the named field is "required". Used by FormField to return a value for FormField::Required(), to do things like show *s on the form template. Returns true if the named field is "required". Used by FormField to return a value for FormField::Required(), to do things like show *s on the form template. #### Overrides `Validator::fieldIsRequired`
`public` | # `getRequired( )` getter function for append getter function for append

### Methods inherited from Validator

`getCombinedError()`, `getError()`, `getErrors()`, `getJavascriptValidationHandler()`, `get_javascript_validator_handler()`, `includeJavascriptValidation()`, `requireField()`, `setForm()`, `setJavascriptValidationHandler()`, `set_javascript_validation_handler()`, `showError()`, `validate()`, `validationError()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `defineMethods()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`protected mixed` | $required | #
`protected boolean` | $useLabels | #

### Properties inherited from Validator

`$errors`, `$form`, `$javascriptValidationHandler`, `$javascript_validation_handler`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -