app/forms/UserSettings.php: extend Httpcb\Form instead of Phalcon\Forms\Form and delete renderDecorated() and _render() as they exists in Httpcb\Form
This commit is contained in:
parent
9cd10581d8
commit
8ff5b5cd1e
1 changed files with 2 additions and 62 deletions
|
|
@ -8,10 +8,9 @@ namespace App\Form;
|
|||
use App\Model\Data\User as UserModel;
|
||||
|
||||
/**
|
||||
* Phalcon Form
|
||||
* Form
|
||||
*/
|
||||
use Phalcon\Forms\Form as FormBase,
|
||||
Phalcon\Forms\Element\AbstractElement;
|
||||
use Httpcb\Form as FormBase;
|
||||
|
||||
/**
|
||||
* Element types
|
||||
|
|
@ -173,63 +172,4 @@ class UserSettings extends FormBase
|
|||
'with' => 'passwordNew',
|
||||
]));
|
||||
}
|
||||
|
||||
public function renderDecorated($name, $opt = [])
|
||||
{
|
||||
$options = [
|
||||
'label-class' => 'control-label',
|
||||
'class' => 'col-sm-10',
|
||||
'message' => ''
|
||||
];
|
||||
|
||||
$ele = $this->get($name);
|
||||
|
||||
if (isset($opt['label-length'])) {
|
||||
$length = (int) $opt['label-length'];
|
||||
} else {
|
||||
$length = 2;
|
||||
}
|
||||
$options['label-class'] .= ' col-sm-' . $length;
|
||||
|
||||
if (isset($opt['length'])) {
|
||||
|
||||
$len = $opt['length'];
|
||||
|
||||
if ($len === 'full') {
|
||||
$options['class'] = '';
|
||||
} else {
|
||||
$options['class'] = 'col-sm-' . $opt['length'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($ele->hasMessages()) {
|
||||
$options['class'] .= ' has-error';
|
||||
$options['message'] = $ele->getMessages()->current();
|
||||
}
|
||||
|
||||
return $this->_render($ele, $options);
|
||||
}
|
||||
|
||||
protected function _render(AbstractElement $ele, $opt)
|
||||
{
|
||||
$xhtml = '';
|
||||
|
||||
if (strlen($ele->getLabel()) > 0) {
|
||||
|
||||
$xhtml .= sprintf(
|
||||
'<label class="%s" for="%s">%s</label>',
|
||||
$opt['label-class'], $ele->getName(), $ele->getLabel());
|
||||
}
|
||||
|
||||
$xhtml .= '<div class="' . $opt['class'] . '">'
|
||||
. $ele->render();
|
||||
|
||||
if (strlen($opt['message']) > 0) {
|
||||
$xhtml .= '<span class="help-block">' . $opt['message'] . '</span>';
|
||||
}
|
||||
|
||||
$xhtml .= '</div>';
|
||||
|
||||
return $xhtml;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue