Cake\View\Helper\FormHelper::fieldset PHP Method

fieldset() public method

Wrap a set of inputs in a fieldset
public fieldset ( string $fields = '', array $options = [] ) : string
$fields string the form inputs to wrap in a fieldset
$options array Options array. Valid keys are: - `fieldset` Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled - `legend` Set to false to disable the legend for the generated input set. Or supply a string to customize the legend text.
return string Completed form inputs.
    public function fieldset($fields = '', array $options = [])
    {
        $fieldset = $legend = true;
        $context = $this->_getContext();
        $out = $fields;
        if (isset($options['legend'])) {
            $legend = $options['legend'];
        }
        if (isset($options['fieldset'])) {
            $fieldset = $options['fieldset'];
        }
        if ($legend === true) {
            $actionName = __d('cake', 'New %s');
            $isCreate = $context->isCreate();
            if (!$isCreate) {
                $actionName = __d('cake', 'Edit %s');
            }
            $modelName = Inflector::humanize(Inflector::singularize($this->request->params['controller']));
            $legend = sprintf($actionName, $modelName);
        }
        if ($fieldset !== false) {
            if ($legend) {
                $out = $this->formatTemplate('legend', ['text' => $legend]) . $out;
            }
            $fieldsetParams = ['content' => $out, 'attrs' => ''];
            if (is_array($fieldset) && !empty($fieldset)) {
                $fieldsetParams['attrs'] = $this->templater()->formatAttributes($fieldset);
            }
            $out = $this->formatTemplate('fieldset', $fieldsetParams);
        }
        return $out;
    }