dirk
1
To style my forms, I need a list of all possible templates for a form.
I found this:
https://api.cakephp.org/3.9/class-Cake.View.Helper.FormHelper.html#%24_defaultConfig
but maybe I’m to dumb to see the templates.
What I already found on the internet are these templates:
> 'checkboxFormGroup' => '<div class="col-xs-5"><div class="checkbox">{{label}}</div></div>',
> 'checkbox' => '<input type="checkbox" value="{{value}}" {{attrs}}>',
> 'checkboxWrapper' => '<div class="form-group"><div class="col-sm-offset-5 col-xs-7">{{label}} {{input}}</div></div>',
> 'inputContainer' => '<div class="form-group" {{required}} >{{content}}</div><div class="hr-line-dashed"></div>',
> 'input' => '<div class="col-xs-7 col-sm-10 col-lg-10"><input class="form-control input-sm" type="{{type}}" name="{{name}}" {{attrs}}></div>',
> 'label' => '<label {{attrs}} class="col-xs-5 col-sm-2 col-lg-2 control-label">{{text}}</label>',
> 'select' => '<div class="col-xs-7 col-sm-10 col-lg-10"><select class="form-control input-sm" {{attrs}} name={{name}}>{{content}}<select></div>',
> 'error' => '<p class="text-danger">{{content}}</p>',
> 'textarea' => '<div class="col-xs-7 col-sm-10 col-lg-10"><textarea class="form-control input-sm" name="{{name}}" {{attrs}}>{{value}}</textarea></div>',
> 'button' => '<div class="form-group"><div class="col-md-12 col-xs-12 col-sm-12 text-center"><button {{attrs}} type="submit">{{text}}</button></div></div>',
> 'inputContainerError' => '<div class="form-group has-error" {{required}}>{{content}}</div>{{error}}',
> 'datetimeContainer' => '<div class="form-group"><div class="input-group date col col-md-10">{{content}}</div></div>',
> 'dateWidget' => '<input type="text" class="form-control" name="{{name}}" {{attrs}} /><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>'
> //'multicheckboxWrapper'=> ''
> //'multicheckboxTitle'
Could someone please provide me a source, where I can find a complete list of the templates used by cakephp?
thanks in advance
dirk
Zuluru
2
Did you search the Cake source code for these? The templates all seem to be defaulted in, unsurprisingly, the FormHelper.
dirk
3
i searched, but did not find it, or maybe did not recognize, that i found it.
tomorrow i start a new search, thanks for your answer
dirk
4
@Zuluru
Thanks again for your hint. I finally found what I was looking for in
/vendor/cakephp/cakephp/src/View/Helper/FormHelper.php
> 'templates' => [
> // Used for button elements in button().
> 'button' => '<button{{attrs}}>{{text}}</button>',
> // Used for checkboxes in checkbox() and multiCheckbox().
> 'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
> // Input group wrapper for checkboxes created via control().
> 'checkboxFormGroup' => '{{label}}',
> // Wrapper container for checkboxes.
> 'checkboxWrapper' => '<div class="checkbox">{{label}}</div>',
> // Error message wrapper elements.
> 'error' => '<div class="error-message">{{content}}</div>',
> // Container for error items.
> 'errorList' => '<ul>{{content}}</ul>',
> // Error item wrapper.
> 'errorItem' => '<li>{{text}}</li>',
> // File input used by file().
> 'file' => '<input type="file" name="{{name}}"{{attrs}}>',
> // Fieldset element used by allControls().
> 'fieldset' => '<fieldset{{attrs}}>{{content}}</fieldset>',
> // Open tag used by create().
> 'formStart' => '<form{{attrs}}>',
> // Close tag used by end().
> 'formEnd' => '</form>',
> // General grouping container for control(). Defines input/label ordering.
> 'formGroup' => '{{label}}{{input}}',
> // Wrapper content used to hide other content.
> 'hiddenBlock' => '<div style="display:none;">{{content}}</div>',
> // Generic input element.
> 'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}/>',
> // Submit input element.
> 'inputSubmit' => '<input type="{{type}}"{{attrs}}/>',
> // Container element used by control().
> 'inputContainer' => '<div class="input {{type}}{{required}}">{{content}}</div>',
> // Container element used by control() when a field has an error.
> 'inputContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>',
> // Label element when inputs are not nested inside the label.
> 'label' => '<label{{attrs}}>{{text}}</label>',
> // Label element used for radio and multi-checkbox inputs.
> 'nestingLabel' => '{{hidden}}<label{{attrs}}>{{input}}{{text}}</label>',
> // Legends created by allControls()
> 'legend' => '<legend>{{text}}</legend>',
> // Multi-Checkbox input set title element.
> 'multicheckboxTitle' => '<legend>{{text}}</legend>',
> // Multi-Checkbox wrapping container.
> 'multicheckboxWrapper' => '<fieldset{{attrs}}>{{content}}</fieldset>',
> // Option element used in select pickers.
> 'option' => '<option value="{{value}}"{{attrs}}>{{text}}</option>',
> // Option group element used in select pickers.
> 'optgroup' => '<optgroup label="{{label}}"{{attrs}}>{{content}}</optgroup>',
> // Select element,
> 'select' => '<select name="{{name}}"{{attrs}}>{{content}}</select>',
> // Multi-select element,
> 'selectMultiple' => '<select name="{{name}}[]" multiple="multiple"{{attrs}}>{{content}}</select>',
> // Radio input element,
> 'radio' => '<input type="radio" name="{{name}}" value="{{value}}"{{attrs}}>',
> // Wrapping container for radio input/label,
> 'radioWrapper' => '{{label}}',
> // Textarea input element,
> 'textarea' => '<textarea name="{{name}}"{{attrs}}>{{value}}</textarea>',
> // Container for submit buttons.
> 'submitContainer' => '<div class="submit">{{content}}</div>',
> // Confirm javascript template for postLink()
> 'confirmJs' => '{{confirm}}',
> // selected class
> 'selectedClass' => 'selected',
> ],