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