Skip to content

Commit

Permalink
FIX: Modal form using wrong template
Browse files Browse the repository at this point in the history
  • Loading branch information
Mellisa Hankins committed Oct 26, 2015
1 parent de40bc5 commit fb06866
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/ModaliseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

class ModaliseForm extends FormBootstrapper
{
public $template = ['Form_Modal', 'Form_Bootstrapped'];

public $title;

public function __construct($original, $title = '')
{
parent::__construct($original);
$this->title = $title;
$this->templateSuffix = '_Modal';
}

public function getFormModalTitle()
Expand Down
29 changes: 18 additions & 11 deletions src/Traits/ViewableDataDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,48 @@

use ViewableData;

trait ViewableDataDecorator {
trait ViewableDataDecorator
{
public $templateSuffix = '_bootstrapped';

public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null) {
public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null)
{
$value = parent::obj($fieldName, $arguments, $forceReturnedObject, $cache, $cacheName);

if(!$value || (is_object($value) && ($value instanceof ViewableData) && !$value->exists())) {
if (!$value || (is_object($value) && ($value instanceof ViewableData) && !$value->exists())) {
return $this->up()->obj($fieldName, $arguments, $forceReturnedObject, $cache, $cacheName);
}
else {
} else {
return $value;
}
}

public function hasMethod($method) {
public function hasMethod($method)
{
return parent::hasMethod($method) || $this->up()->hasMethod($method);
}

public function __call($method, $arguments) {
$return = call_user_func_array(array($this->pullUp, $method), $arguments);
public function __call($method, $arguments)
{
$return = call_user_func_array([$this->pullUp, $method], $arguments);

if($return === $this->original()) {
if ($return === $this->original()) {
// Trying to support chain commands
return $this;
}

return $return;
}

protected function suffixTemplates(array $templates)
protected function suffixTemplates(array $templates, $suffix = '')
{
if (!$suffix) {
$suffix = $this->templateSuffix;
}

$new = [];

foreach ($templates as $template) {
$new[] = str_replace('\\', '_', $template) . $this->templateSuffix;
$new[] = str_replace('\\', '_', $template) . $suffix;
}

return array_unique(array_merge($new, $templates));
Expand Down

0 comments on commit fb06866

Please sign in to comment.