Juzaweb CMS provides a powerful and fluent API for generating form fields using the Field facade. These fields are typically used in Meta Box registrations, Settings pages, or custom Admin forms.
use Juzaweb\Modules\Core\Facades\Field;
// Basic syntax
Field::text($label, $name, $options);
// Fluent chaining (Recommended)
Field::select('Status', 'status')->options(['on' => 'On', 'off' => 'Off']);All fields accept an $options array as the third argument, or you can use fluent methods to set them.
| Option | Fluent Method | Description |
|---|---|---|
default |
value($value) |
Set default value |
id |
id($id) |
Custom ID attribute |
class |
classes($class) |
Custom CSS classes |
disabled |
disabled($bool) |
Disable the input |
help |
help($text) |
Help text displayed below input |
placeholder |
placeholder($text) |
Input placeholder |
Standard text input.
Field::text('Full Name', 'name')
->placeholder('Enter your name')
->help('Please enter your real name');Multiline text input.
Field::textarea('Bio', 'bio')
->rows(5); // Set number of rows (if supported via options)WYSIWYG Editor.
Field::editor('Content', 'content');Dropdown list with support for Select2, AJAX loading, and multiple selection.
// Static Options
Field::select('Status', 'status')
->dropDownList(['published' => 'Published', 'draft' => 'Draft']);
// Collection Options
Field::select('User', 'user_id')
->dropDownList(User::all(), 'id', 'name');
// Multiple Select
Field::select('Categories', 'categories')
->multiple();
// AJAX Search (Select2)
Field::select('Author', 'author_id')
->loadDataModel('Juzaweb\Modules\Admin\Models\User', 'name');
// OR Custom URL
Field::select('Author', 'author_id')
->dataUrl(route('admin.authors.search'));Single image uploader. Automatically handles file manager integration.
Field::image('Thumbnail', 'thumbnail');Gallery uploader (Multiple images).
Field::images('Gallery', 'gallery');Flexible input for uploading files or entering a URL (useful for Videos/Files).
Field::uploadUrl('Video Source', 'video_url')
->uploadType('video') // 'image', 'file', 'video', 'audio'
->disk('public'); // 'public', 's3', etc.Single checkbox toggle.
Field::checkbox('Is Featured', 'is_featured')
->checked(true); // default checkedDate picker.
Field::date('Publish Date', 'publish_date')
->format('Y-m-d'); // Default formatTag input interface.
Field::tags('Tags', 'tags');Auto-generating slug field.
// Automatically listens to the 'name' field changes to update slug
Field::slug('Slug', 'slug')
->target('name'); // The field name to watchSecurity Code / Captcha field (implementation depends on config).
Field::security('Verify Code', 'security_code');Currency input format.
Field::currency('Price', 'price');Dropdown to select system languages.
Field::language('Language', 'language_code');You can register your own field types extending the Juzaweb\Modules\Core\Support\Fields\Field abstract class.
-
Create class extending
FieldCreate a new class, for example
Color.php, and extend theFieldclass.namespace Juzaweb\Modules\Core\Support\Fields; use Juzaweb\Modules\Core\Support\Fields\Field; class Color extends Field { // ... }
-
Implement
render()method returning a ViewImplement the
rendermethod to return the blade view for your field.use Illuminate\Contracts\View\View; class Color extends Field { public function render(): View|string { // You can pass params to view using $this->renderParams() return view( 'theme::components.fields.color', $this->renderParams() ); } }
-
Register using
Field::macroor extendingFieldFactoryRegister the new field in your
ServiceProvider(e.g.,AppServiceProvideror a Module Service Provider).use Juzaweb\Modules\Core\Facades\Field; use Juzaweb\Modules\Core\Support\Fields\Color; public function boot() { Field::macro('color', function ($label, $name, $options = []) { return new Color($label, $name, $options); }); }
Now you can use your new field type using the macro name you registered.
Field::color('Background Color', 'bg_color');