Merge branch 'dev' into 31-admin-user-management
# Conflicts: # app/forms/UserSettings.php
This commit is contained in:
commit
4b750f0f37
70 changed files with 7831 additions and 5620 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 as FormElement;
|
||||
use Httpcb\Form as FormBase;
|
||||
|
||||
/**
|
||||
* Element types
|
||||
|
|
@ -56,13 +55,16 @@ class UserSettings extends FormBase
|
|||
|
||||
// Id
|
||||
if ($entity && $entity->getId()) {
|
||||
$id = new Text('id', array(
|
||||
'class' => 'form-control',
|
||||
'readonly' => '',
|
||||
));
|
||||
|
||||
$id = new Text('id', array(
|
||||
'class' => 'form-control',
|
||||
'readonly' => '',
|
||||
'disabled' => 'disabled',
|
||||
));
|
||||
|
||||
$id->addValidator(new IdenticalValidator([
|
||||
'accepted' => $entity->getId(),
|
||||
'allowEmpty' => true
|
||||
]));
|
||||
|
||||
$id->setLabel('ID');
|
||||
|
|
@ -114,10 +116,12 @@ class UserSettings extends FormBase
|
|||
'class' => 'form-control',
|
||||
'placeholder' => 'Email',
|
||||
'readonly' => '',
|
||||
'disabled' => 'disabled',
|
||||
));
|
||||
|
||||
$email->addValidator(new IdenticalValidator([
|
||||
'accepted' => $entity->getEmail(),
|
||||
'allowEmpty' => true
|
||||
]));
|
||||
} else {
|
||||
$email = new Text('email', array(
|
||||
|
|
@ -215,63 +219,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(FormElement $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