Skip to content

Commit

Permalink
Merge pull request #341 from holmesadam/hidden-label
Browse files Browse the repository at this point in the history
Allow label to be hidden on all fields
  • Loading branch information
atmonshi authored Dec 24, 2024
2 parents a978ac2 + 48aa4fe commit b24bdd5
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"fields per row" :"عدد الحقول في كل صف",
"Full Width" :"كامل العرض",
"show this field in full width row" :"عرض هذا الحقل في صف منفصل",
"Hidden Label": "اخفاء العنوان",
"open" :"عرض",
"Open Form" :"عرض النموذج",
"Conditional Visibility" :"ظهور الحقل بشرط",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/ckb.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"fields per row" :" بەشەکان بۆ هەر ڕیزێک",
"Full Width" :"پانی تەواو",
"show this field in full width row" :"ئەم بەشە بە ڕیزی تەواوی پانایی نیشان بدە",
"Hidden Label": "Hidden Label",
"open" :"کردنەوە",
"Open Form" :"کردنەوەی فۆڕم",
"Conditional Visibility" :"بینینی مەرجدار",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"fields per row" :"fields per row",
"Full Width" :"Full Width",
"show this field in full width row" :"show this field in full width row",
"Hidden Label": "Verstecktes Etikett",
"open" :"open",
"Open Form" :"Open Form",
"Conditional Visibility" :"Conditional Visibility",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"fields per row" :"fields per row",
"Full Width" :"Full Width",
"show this field in full width row" :"show this field in full width row",
"Hidden Label": "Hidden Label",
"open" :"open",
"Open Form" :"Open Form",
"Conditional Visibility" :"Conditional Visibility",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"fields per row" :"campos por fila",
"Full Width" :"Ancho Completo",
"show this field in full width row" :"mostrar este campo en una fila de ancho completo",
"Hidden Label": "Etiqueta Oculta",
"open" :"abrir",
"Open Form" :"Abrir Formulario",
"Conditional Visibility" :"Visibilidad Condicional",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"fields per row" :"fields per row",
"Full Width" :"Full Width",
"show this field in full width row" :"show this field in full width row",
"Hidden Label": "Étiquette cachée",
"open" :"open",
"Open Form" :"Open Form",
"Conditional Visibility" :"Conditional Visibility",
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasHiddenOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public static function hiddenColumnSpanFull(): array
];
}

public static function hiddenHiddenLabel(): array
{
return [
Hidden::make('options.hidden_label')->default(false),
];
}

public static function hiddenDataSource(): array
{
return [
Expand Down
10 changes: 10 additions & 0 deletions src/Concerns/HasOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ public static function columnSpanFull(): Grid
->columns(1);
}

public static function hiddenLabel(): Grid
{
return Grid::make()
->schema([
Toggle::make('options.hidden_label')
->label(__('Hidden Label')),
])
->columns(1);
}

public static function dataSource(): Grid
{
$dataSources = BoltPlugin::getModel('Collection')::get()
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/CheckboxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -66,6 +67,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
];
}

Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/ColorPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static function getOptions(?array $sections = null): array
]),
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -66,6 +67,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
self::hiddenVisibility(),
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -60,6 +61,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
self::hiddenVisibility(),
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -60,6 +61,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
self::hiddenVisibility(),
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static function getOptions(?array $sections = null): array
\Filament\Forms\Components\Toggle::make('options.allow_multiple')->label(__('Allow Multiple')),
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -61,6 +62,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
self::hiddenVisibility(),
Hidden::make('options.allow_multiple')->default(false),
];
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/Paragraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->icon('iconpark-checklist-o')
->schema([
self::columnSpanFull(),
self::hiddenLabel(),
self::hintOptions(),
]),
self::visibility($sections),
Expand All @@ -51,6 +52,7 @@ public static function getOptionsHidden(): array
return [
self::hiddenHintOptions(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
self::hiddenVisibility(),
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
self::required(),
Toggle::make('options.is_inline')->label(__('Is inline')),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -67,6 +68,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
Hidden::make('options.dataSource'),
Hidden::make('options.is_inline')->default(false),
];
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/RichEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -61,6 +62,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
];
}
}
2 changes: 2 additions & 0 deletions src/Fields/Classes/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -69,6 +70,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
Hidden::make('options.dataSource'),
Hidden::make('options.allow_multiple')->default(false),
];
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->label(__('Suffix Icon Color')),

self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -132,6 +133,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),

Hidden::make('options.dateType'),

Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)

self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -83,6 +84,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
Hidden::make('options.rows'),
Hidden::make('options.cols'),
Hidden::make('options.minLength'),
Expand Down
2 changes: 2 additions & 0 deletions src/Fields/Classes/TimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
->schema([
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -61,6 +62,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
];
}
}
2 changes: 2 additions & 0 deletions src/Fields/Classes/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static function getOptions(?array $sections = null, ?array $field = null)
]),
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
self::htmlID(),
]),
self::hintOptions(),
Expand All @@ -97,6 +98,7 @@ public static function getOptionsHidden(): array
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
Hidden::make('options.on-icon'),
Hidden::make('options.off-icon'),
Hidden::make('options.on-color'),
Expand Down
4 changes: 4 additions & 0 deletions src/Fields/FieldsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public function appendFilamentComponentsOptions($component, $zeusField, bool $ha
$component = $component->columnSpanFull();
}

if (optional($zeusField->options)['hidden_label']) {
$component = $component->hiddenLabel();
}

if (optional($zeusField->options)['hint']) {
if (optional($zeusField->options)['hint']['text']) {
$component = $component->hint($zeusField->options['hint']['text']);
Expand Down
2 changes: 2 additions & 0 deletions stubs/ZeusField.stub
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class {{ class }} extends FieldsContract
self::htmlID(),
self::required(),
self::columnSpanFull(),
self::hiddenLabel(),
];
}

Expand All @@ -31,6 +32,7 @@ class {{ class }} extends FieldsContract
self::hiddenHtmlID(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
self::hiddenHiddenLabel(),
];
}
}
Expand Down

0 comments on commit b24bdd5

Please sign in to comment.