1. Go to this page and download the library: Download digitalnodecom/larafields library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitalnodecom / larafields example snippets
return [
'forms' => [
[
'label' => 'Your Field Group Name',
'name' => 'unique_field_group_name',
'settings' => [
'showInRestApi' => true,
'storage' => [
'type' => 'json',
'location' => 'shared_table'
],
'conditions' => [
// Define where to display the form
]
],
'fields' => [
// Your field definitions
]
]
]
];
[
'type' => 'multiselect',
'label' => 'Multiple Choice',
'name' => 'multiselect_field',
'defaultValue' => '',
'2',
'label' => 'Option 2'
]
],
'custom_values' => false // Set to true to allow users to enter custom values not in the options list
]
// Get all fields for a specific object
$fields = FormMaker::get_field(objectName: 'product', objectId: '123');
// Get a specific field
$field = FormMaker::get_field(fieldKey: 'product_gender');
// Get fields by object name
$fields = FormMaker::get_field(objectName: 'product');
use Illuminate\Support\Collection;
add_filter('larafields_load_fields', function(Collection $fields){
// Manipulate the $fields collection.
});
add_filter('larafields_load_pages', function ($pages) {
return [
[
'type' => 'page',
'page_title' => 'Example Page',
'menu_title' => 'Example Page',
'slug' => 'page-example',
// 'hide_from_submenu' => true // This prevents the parent page from appearing in the submenu
],
];
});