'{$settings['placeholder']}'" : ""; $options[] = isset($item['value']) ? "'value' => '{$settings['value']}'" : ""; $options[] = isset($item['maxlength']) ? "'maxlength' => true" : ""; $options = implode(',', array_filter($options)); $description = isset($item['description']) ? $settings['description'] : ''; $field = "field(\$model, '{$settings['name']}')->textInput([{$options}])->hint('{$description}') ?>"; return $field; } public function textArea(array $settings): string { $options = []; $options[] = isset($item['rows']) ? "'rows' => {$settings['rows']}" : ""; $options[] = isset($item['placeholder']) ? "'placeholder' => '{$settings['placeholder']}'" : ""; $options[] = isset($item['value']) ? "'value' => '{$settings['value']}'" : ""; $options = implode(',', array_filter($options)); $description = isset($item['description']) ? $settings['description'] : ''; $field = "field(\$model, '{$settings['name']}')->textarea([{$options}])->hint('{$description}') ?>"; return $field; } public function header(array $settings): string { $field = "<{$settings['subtype']}>{$settings['label']}"; return $field; } public function paragraph(array $settings): string { $field = "<{$settings['subtype']}>{$settings['label']}"; return $field; } public function hidden(array $settings): string { $options = []; $options[] = isset($item['value']) ? "'value' => '{$settings['value']}'" : ""; $options = implode(',', array_filter($options)); $field = "field(\$model, '{$settings['name']}')->hiddenInput([{$options}])->label(false) ?>"; return $field; } public function radioGroup(array $settings): string { $values = []; $selected = []; foreach ($settings['values'] as $value) { $values[] = "'{$value['value']}' => '{$value['label']}'"; if (isset($value['selected']) && $value['selected'] == true) { $selected[] = "'{$value['value']}'"; } } $values = implode(',', $values); $selected = implode(',', $selected); if ($selected) { $fields[] = "{$settings['name']} = [{$selected}] ?>"; } $options = []; $options = implode(',', array_filter($options)); $description = isset($settings['description']) ? $settings['description'] : ''; $field = "field(\$model, '{$settings['name']}') ->radioList([ {$values} ], [{$options}])->hint('{$description}'); ?>"; return $field; } public function checkboxGroup(array $settings): string { $values = []; $selected = []; foreach ($settings['values'] as $value) { $values[] = "'{$value['value']}' => '{$value['label']}'"; if (isset($value['selected']) && $value['selected'] == true) { $selected[] = "'{$value['value']}'"; } } $values = implode(',', $values); $selected = implode(',', $selected); if ($selected) { $fields[] = "{$settings['name']} = [{$selected}] ?>"; } $options = []; $options = implode(',', array_filter($options)); $description = isset($settings['description']) ? $settings['description'] : ''; $field = "field(\$model, '{$settings['name']}') ->checkboxList([ {$values} ], [{$options}])->hint('{$description}'); ?>"; return $field; } public function select(array $settings): string { $values = []; $selected = []; foreach ($settings['values'] as $value) { $values[] = "'{$value['value']}' => '{$value['label']}'"; if (isset($value['selected']) && $value['selected'] == true) { $selected[] = "'{$value['value']}'"; } } $values = implode(',', $values); $selected = implode(',', $selected); $options = []; $options[] = $selected ? "'value' => [{$selected}]" : ""; $options[] = isset($settings['placeholder']) ? "'prompt' => '{$settings['placeholder']}'" : ""; $options[] = isset($settings['multiple']) && $settings['multiple'] == true ? "'multiple' => 'multiple'" : ""; $options = implode(',', array_filter($options)); $description = isset($settings['description']) ? $settings['description'] : ''; $field = "field(\$model, '{$settings['name']}')->dropDownList([{$values}], [{$options}])->hint('{$description}') ?>"; return $field; } public function button(array $settings): string { $style = isset($settings['style']) ? $settings['style'] : 'default'; if ($settings['subtype'] == 'submit') { $field = "
'btn btn-{$style}']) ?>
"; return $field; } elseif ($settings['subtype'] == 'button') { $field = "
'btn btn-{$style}']) ?>
"; return $field; } elseif ($settings['subtype'] == 'reset') { $field = "
'btn btn-{$style}']) ?>
"; return $field; } return ''; } }