parent
5d4afff97f
commit
bcff1d3ecd
|
|
@ -4,6 +4,7 @@ use Str;
|
||||||
use File;
|
use File;
|
||||||
use Session;
|
use Session;
|
||||||
use October\Rain\Html\Helper as HtmlHelper;
|
use October\Rain\Html\Helper as HtmlHelper;
|
||||||
|
use October\Rain\Extension\Extendable;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -12,7 +13,7 @@ use stdClass;
|
||||||
* @package october\backend
|
* @package october\backend
|
||||||
* @author Alexey Bobkov, Samuel Georges
|
* @author Alexey Bobkov, Samuel Georges
|
||||||
*/
|
*/
|
||||||
abstract class WidgetBase
|
abstract class WidgetBase extends Extendable
|
||||||
{
|
{
|
||||||
use \System\Traits\ViewMaker;
|
use \System\Traits\ViewMaker;
|
||||||
use \System\Traits\AssetMaker;
|
use \System\Traits\AssetMaker;
|
||||||
|
|
@ -71,6 +72,8 @@ abstract class WidgetBase
|
||||||
*/
|
*/
|
||||||
$this->loadAssets();
|
$this->loadAssets();
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the widget.
|
* Initialize the widget.
|
||||||
*/
|
*/
|
||||||
|
|
@ -111,7 +114,7 @@ abstract class WidgetBase
|
||||||
public function bindToController()
|
public function bindToController()
|
||||||
{
|
{
|
||||||
if ($this->controller->widget === null) {
|
if ($this->controller->widget === null) {
|
||||||
$this->controller->widget = new \stdClass();
|
$this->controller->widget = new stdClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->controller->widget->{$this->alias} = $this;
|
$this->controller->widget->{$this->alias} = $this;
|
||||||
|
|
|
||||||
|
|
@ -1031,8 +1031,8 @@ class Form extends WidgetBase
|
||||||
|
|
||||||
$methodName = 'get'.studly_case($attribute).'Options';
|
$methodName = 'get'.studly_case($attribute).'Options';
|
||||||
if (
|
if (
|
||||||
!$this->methodExists($model, $methodName) &&
|
!$this->objectMethodExists($model, $methodName) &&
|
||||||
!$this->methodExists($model, 'getDropdownOptions')
|
!$this->objectMethodExists($model, 'getDropdownOptions')
|
||||||
) {
|
) {
|
||||||
throw new ApplicationException(Lang::get(
|
throw new ApplicationException(Lang::get(
|
||||||
'backend::lang.field.options_method_not_exists',
|
'backend::lang.field.options_method_not_exists',
|
||||||
|
|
@ -1040,7 +1040,7 @@ class Form extends WidgetBase
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->methodExists($model, $methodName)) {
|
if ($this->objectMethodExists($model, $methodName)) {
|
||||||
$fieldOptions = $model->$methodName($field->value);
|
$fieldOptions = $model->$methodName($field->value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -1051,7 +1051,7 @@ class Form extends WidgetBase
|
||||||
* Field options are an explicit method reference
|
* Field options are an explicit method reference
|
||||||
*/
|
*/
|
||||||
elseif (is_string($fieldOptions)) {
|
elseif (is_string($fieldOptions)) {
|
||||||
if (!$this->methodExists($this->model, $fieldOptions)) {
|
if (!$this->objectMethodExists($this->model, $fieldOptions)) {
|
||||||
throw new ApplicationException(Lang::get(
|
throw new ApplicationException(Lang::get(
|
||||||
'backend::lang.field.options_method_not_exists',
|
'backend::lang.field.options_method_not_exists',
|
||||||
['model'=>get_class($this->model), 'method'=>$fieldOptions, 'field'=>$field->fieldName]
|
['model'=>get_class($this->model), 'method'=>$fieldOptions, 'field'=>$field->fieldName]
|
||||||
|
|
@ -1099,7 +1099,7 @@ class Form extends WidgetBase
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function methodExists($object, $method)
|
protected function objectMethodExists($object, $method)
|
||||||
{
|
{
|
||||||
if (method_exists($object, 'methodExists')) {
|
if (method_exists($object, 'methodExists')) {
|
||||||
return $object->methodExists($method);
|
return $object->methodExists($method);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue