PHP code example of unclecheese / zen-fields

1. Go to this page and download the library: Download unclecheese/zen-fields 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/ */

    

unclecheese / zen-fields example snippets



$fields
  ->text("FirstName")
  ->numeric("Age");


$fields->addFieldToTab("Root.Main", TextField::create("FirstName", "First Name"),"Content");
$fields->addFieldToTab("Root.Main", TextField::create("Age", "Age"),"Content");


$fields
  ->tab("PersonalInfo")
    ->text("FirstName")
    ->numeric("Age")
  ->tab("Qualifications")
    ->grid("Qualifications","Qualifications", $this->Qualifications(), GridFieldConfig_RecordEditor::create());
    


$fields
  ->dropdown("PickOne")
    ->configure()
      ->setSource(array('1' => 'One', '2' => 'Two'))
      ->setEmptyString("-- None --")
    ->end()
  ->text("Title");


$fields->addFieldToTab("Root.Main", DropdownField::create("PickOne","Pick One")
  ->setSource(array('1' => 'One', '2' => 'Two'))
  ->setEmptyString("-- None --")
);
$fields->addFieldToTab("Root.Main", TextField::create("Title"));


$fields
  ->text("Name")
  ->group()
    ->text("Address")
    ->text("City")
    ->text("PostalCode")
  ->end();


$fields->addFieldToTab("Root.Main", TextField::create("Name"));
$fields->addFieldToTab("Root.Main", FieldGroup::create(
  TextField::create("Address"),
  TextField::create("City")
  TextField::create("PostalCode")
));


$fields
  ->imageUpload("MyImage")
  ->hasManyGrid("RelatedObjects","Related objects", $this->RelatedObjects())
    ->configure()->addDragAndDrop("Sort")->end();