From 0e0adcb05f7d52db0c22a612591f18b6381afdd0 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Thu, 11 Feb 2016 04:27:15 +0100 Subject: [PATCH] Little fixes in serializefield and multilangform --- src/CoreFields/SerializeField.php | 19 ++++++++++++++++--- src/Forms/MultiLangForm.php | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/CoreFields/SerializeField.php b/src/CoreFields/SerializeField.php index 33d22fc..10c204a 100644 --- a/src/CoreFields/SerializeField.php +++ b/src/CoreFields/SerializeField.php @@ -18,6 +18,7 @@ class SerializeField extends PhangoField { public $quot_close='\''; public $std_error=''; public $related_type=''; + public $callback_values='PhangoApp\PhaModels\CoreFields\SerializeField::set_format'; //type_data can be any field type that is loaded IntegerField, etc.. @@ -90,13 +91,25 @@ class SerializeField extends PhangoField { public function show_formatted($value) { - - $real_value=unserialize($value); - return implode(', ', $return_value); + return $this->callback_values($value); } + /** + * Method for choose the callback method for format the value + */ + + static public function set_format($serialize_value) + { + + $real_value=unserialize($value); + + return implode(', ', $return_value); + + } + + static function unserialize($value) { diff --git a/src/Forms/MultiLangForm.php b/src/Forms/MultiLangForm.php index 962c8cc..0cbd600 100644 --- a/src/Forms/MultiLangForm.php +++ b/src/Forms/MultiLangForm.php @@ -11,10 +11,10 @@ class MultiLangForm extends BaseForm{ public $type_form; - public function __construct($name, $value) + public function __construct($name, $value, $type_form='PhangoApp\PhaModels\Forms\BaseForm') { - $this->type_form=new BaseForm($name, $value); + $this->type_form=new $type_form($name, $value); parent::__construct($name, $value);