Skip to content

Commit 97a77be

Browse files
committed
update Ubiquity renderView
1 parent d463f7f commit 97a77be

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Diff for: Ajax/php/ubiquity/JsUtils.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class JsUtils extends \Ajax\JsUtils {
1515
*/
1616
protected function _open_script($src = '') {
1717
$str = '<script ';
18-
if (($this->params['csp']??false)==='nonce' && ContentSecurityManager::isStarted()) {
18+
if (($this->params['csp'] ?? false) === 'nonce' && ContentSecurityManager::isStarted()) {
1919
$nonce = ContentSecurityManager::getNonce('jsUtils');
2020
$str .= ' nonce="' . $nonce . '" ';
2121
}
@@ -24,14 +24,13 @@ protected function _open_script($src = '') {
2424
}
2525

2626
public function inline($script, $cdata = true) {
27-
if (($this->params['csp']??false)==='hash' && ContentSecurityManager::isStarted()) {
28-
$script= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
29-
ContentSecurityManager::getHash('jsUtils',$script);
27+
if (($this->params['csp'] ?? false) === 'hash' && ContentSecurityManager::isStarted()) {
28+
$script = ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
29+
ContentSecurityManager::getHash('jsUtils', $script);
3030
}
31-
return $this->_open_script().$script.$this->_close_script();
31+
return $this->_open_script() . $script . $this->_close_script();
3232
}
3333

34-
3534
public function getUrl($url) {
3635
return URequest::getUrl($url);
3736
}
@@ -75,9 +74,7 @@ public function renderView($viewName, $parameters = [], $asString = false) {
7574
if (isset($this->injected)) {
7675
$view = $this->injected->getView();
7776
$this->compile($view);
78-
if (isset($parameters))
79-
$view->setVars($parameters);
80-
return $view->render($viewName, $asString);
77+
return $this->injected->loadView($viewName, $parameters, $asString);
8178
}
8279
throw new \Exception(get_class() . " instance is not properly instancied : you omitted the second parameter \$controller!");
8380
}

Diff for: Ajax/semantic/html/collections/form/HtmlFormField.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Ajax\semantic\html\collections\form;
33

44
use Ajax\JsUtils;
5+
use Ajax\semantic\components\validation\Rule;
56
use Ajax\semantic\html\base\HtmlSemDoubleElement;
67
use Ajax\semantic\html\base\constants\Wide;
78
use Ajax\semantic\html\base\constants\State;
@@ -140,7 +141,11 @@ public function addRule($type, $prompt = NULL, $value = NULL) {
140141
if (! isset($this->_validation)) {
141142
$this->_validation = new FieldValidation($field->getIdentifier());
142143
}
143-
if ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
144+
if($type instanceof Rule){
145+
if($type->getType()=='empty'){
146+
$this->addToProperty('class', 'required');
147+
}
148+
}elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
144149
$this->addToProperty('class', 'required');
145150
}
146151
$this->_validation->addRule($type, $prompt, $value);

0 commit comments

Comments
 (0)