PHP code example of phil / field-layout

1. Go to this page and download the library: Download phil/field-layout 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/ */

    

phil / field-layout example snippets


use Phil\FieldLayout\ArrayLayoutReader;
use Phil\FieldLayout\LayoutJudge;

$layout = new ArrayLayoutReader()->read([
    'context' => ['is_staff'],
    'tabs' => [
        ['name' => 'general', 'label' => 'General', 'fields' => [
            ['field' => 'title', 'tip' => 'Shown in the catalogue.'],
            ['field' => 'price', 'width' => 2, 'editable_when' => ['var' => 'is_staff']],
            ['field' => 'has_prerequisite', 'width' => 2],
            ['field' => 'prerequisite', 'visible_when' => ['var' => 'has_prerequisite']],
        ]],
    ],
]);

$decision = new LayoutJudge()->judge($layout, $submitted, $stored, ['is_staff' => $isStaff]);
$decision->validated(); // the handles to validate
$decision->values;      // the values to write, nothing else