PHP code example of lrnzfrr / custom-fields

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

    

lrnzfrr / custom-fields example snippets


bin/cake plugin load lrnzfrr/CustomFields

        $this->addBehavior('lrnzfrr/CustomFields.CustomFieldable',
                          ['accessibleFields'=>['article_type','article_status']  // custom fields accessible
                          ]);

    $articles = $this->Articles->find('withCustomFields');

        echo $this->Form->hidden('custom_fields.0.name',['value'=>'article_type']);
        echo $this->Form->text('custom_fields.0.value',['value'=>'','label'=>'article_type','placeholder'=>'Article Type']);

        echo $this->Form->hidden('custom_fields.1.name',['value'=>'article_status']);
        echo $this->Form->text('custom_fields.1.value',['value'=>'','label'=>'article_status','placeholder'=>'Article Status']);

use lrnzfrr\CustomFields\Model\Traits\CustomFieldTrait;

class ....
use CustomFieldTrait;
protected $_virtual = ['custom_fields_assoc'];

    /*
    ** Create a virtual property with custom Fields
    */
    protected function _getCustomFieldsAssoc()
    {
        return $this->getCustomFieldsAssoc();
    }