'{$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 { return "<{$settings['subtype']}>{$settings['label']}"; } public function paragraph(array $settings): string { return "<{$settings['subtype']}>{$settings['label']}"; } public function hidden(array $settings): string { $options = []; $options[] = isset($item['value']) ? "'value' => '{$settings['value']}'" : ""; $options = implode(',', array_filter($options)); return "field(\$model, '{$settings['name']}')->hiddenInput([{$options}])->label(false) ?>"; } 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 = $settings['description'] ?? ''; return "field(\$model, '{$settings['name']}') ->radioList([ {$values} ], [{$options}])->hint('{$description}'); ?>"; } 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 = $settings['description'] ?? ''; return "field(\$model, '{$settings['name']}') ->checkboxList([ {$values} ], [{$options}])->hint('{$description}'); ?>"; } 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 = $settings['description'] ?? ''; return "field(\$model, '{$settings['name']}')->dropDownList([{$values}], [{$options}])->hint('{$description}') ?>"; } public function button(array $settings): string { $style = $settings['style'] ?? 'default'; if ($settings['subtype'] == 'submit') { return "
'btn btn-{$style}']) ?>
"; } elseif ($settings['subtype'] == 'button') { return "
'btn btn-{$style}']) ?>
"; } elseif ($settings['subtype'] == 'reset') { return "
'btn btn-{$style}']) ?>
"; } return ''; } }