mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
By convention store custom fields data in the parameter cFData -- close #639
This commit is contained in:
parent
3934d18df3
commit
a88e8cb6f7
@ -48,6 +48,10 @@ Allow custom fields on an entity
|
|||||||
|
|
||||||
As a developer, you must allow your users to add custom fields on your entities.
|
As a developer, you must allow your users to add custom fields on your entities.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
For having custom fields, the class of the entity must contain a variable for storing the custom data. **By convention this variable must be called $cFData**
|
||||||
|
|
||||||
|
|
||||||
Create a json field on your entity
|
Create a json field on your entity
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
@ -59,7 +63,7 @@ Declare a json field in your database :
|
|||||||
type: entity
|
type: entity
|
||||||
# ...
|
# ...
|
||||||
fields:
|
fields:
|
||||||
customField:
|
cFData:
|
||||||
type: json_array
|
type: json_array
|
||||||
|
|
||||||
Create the field accordingly in the class logic :
|
Create the field accordingly in the class logic :
|
||||||
@ -77,18 +81,18 @@ Create the field accordingly in the class logic :
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $customField;
|
private $cFData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You must set a setter in order to save automatically custom
|
* You must set a setter in order to save automatically custom
|
||||||
* fields from forms, using Form Component
|
* fields from forms, using Form Component
|
||||||
*
|
*
|
||||||
* @param array $customField
|
* @param array $cFData
|
||||||
* @return BlopEntity
|
* @return BlopEntity
|
||||||
*/
|
*/
|
||||||
public function setCustomField(array $customField)
|
public function setCFData(array $cFData)
|
||||||
{
|
{
|
||||||
$this->customField = $customField;
|
$this->cFData = $cFData;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +102,9 @@ Create the field accordingly in the class logic :
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCustomField()
|
public function getCFData()
|
||||||
{
|
{
|
||||||
return $this->customField;
|
return $this->cFData;
|
||||||
}
|
}
|
||||||
|
|
||||||
Declare your customizable entity in configuration
|
Declare your customizable entity in configuration
|
||||||
|
Loading…
x
Reference in New Issue
Block a user