Skip to content

View Helpers

hasManyCheckBox()

hasManyCheckBox() — returns string

Available in: controller Category: Form Association Functions

Used as a shortcut to output the proper form elements for an association. Note: Pass any additional arguments like class, rel, and id, and the generated tag will also include those values as HTML attributes.

NameTypeRequiredDefaultDescription
objectNamestringyesName of the variable containing the parent object to represent with this form field.
associationstringyesName of the association set in the parent object to represent with this form field.
keysstringyesPrimary keys associated with this form field. Note that these keys should be listed in the order that they appear in the database table.
labelstringnoThe label text to use in the form control.
labelPlacementstringnoWhether to place the label before, after, or wrapped around the form control. Label text placement can be controlled using aroundLeft or aroundRight.
prependstringnoString to prepend to the form control. Useful to wrap the form control with HTML tags.
appendstringnoString to append to the form control. Useful to wrap the form control with HTML tags.
prependToLabelstringnoString to prepend to the form control’s label. Useful to wrap the form control with HTML tags.
appendToLabelstringnoString to append to the form control’s label. Useful to wrap the form control with HTML tags.
errorElementstringnoHTML tag to wrap the form control with when the object contains errors.
errorClassstringnoThe class name of the HTML tag that wraps the form control when there are errors.
encodeanynotrueUse this argument to decide whether the output of the function should be encoded in order to prevent Cross Site Scripting (XSS) attacks. Set it to true to encode all relevant output for the specific HTML element in question (e.g. tag content, attribute values, and URLs). For HTML elements that have both tag content and attribute values you can set this argument to attributes to only encode attribute values and not tag content.
idstringnoOptional. Explicit ID for the generated checkbox input. If not provided, an ID will be generated automatically.