Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Input of type password to the CustomFormField possibilities #37

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,15 @@ return [
'rules' => 'required|string|max:255',
],
'custom_field_2' => [
'type' => 'password',
'label' => 'Custom Password field 2',
'placeholder' => 'Custom Password Field 2',
'required' => true,
'rules' => 'required|string|max:255',
],
'custom_field_3' => [
'type' => 'select',
'label' => 'Custom Select 2',
'label' => 'Custom Select 3',
'placeholder' => 'Select',
'required' => true,
'options' => [
Expand All @@ -298,22 +305,22 @@ return [
'option_3' => 'Option 3',
],
],
'custom_field_3' => [
'custom_field_4' => [
'type' =>'textarea',
'label' => 'Custom Textarea 3',
'label' => 'Custom Textarea 4',
'placeholder' => 'Textarea',
'rows' => '3',
'required' => true,
],
'custom_field_4' => [
'custom_field_5' => [
'type' => 'datetime',
'label' => 'Custom Datetime 4',
'label' => 'Custom Datetime 5',
'placeholder' => 'Datetime',
'seconds' => false,
],
'custom_field_5' => [
'custom_field_6' => [
'type' => 'boolean',
'label' => 'Custom Boolean 5',
'label' => 'Custom Boolean 6',
'placeholder' => 'Boolean'
],
]
Expand Down
12 changes: 12 additions & 0 deletions src/Livewire/CustomFieldsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ private static function createField(string $fieldKey, array $field): ?Forms\Comp
switch ($field['type']) {
case 'text':
return self::createTextInput($fieldKey, $field);
case 'password':
return self::createPasswordInput($fieldKey, $field);
case 'boolean':
return self::createCheckbox($fieldKey, $field);
case 'select':
Expand All @@ -81,6 +83,16 @@ private static function createTextInput(string $fieldKey, array $field): TextInp
->rules($field['rules']);
}

private static function createPasswordInput(string $fieldKey, array $field): TextInput
{
return TextInput::make($fieldKey)
->label(__($field['label']))
->placeholder(__($field['placeholder']))
->required($field['required'])
->password()
->rules($field['rules']);
}

private static function createCheckbox(string $fieldKey, array $field): Checkbox
{
return Checkbox::make($fieldKey)
Expand Down