1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
<?php
namespace Nethgui\Widget\Xhtml;
class TextInput extends \Nethgui\Widget\XhtmlWidget
{
protected function getJsWidgetTypes()
{
return array_merge(array('Nethgui:inputcontrol'), parent::getJsWidgetTypes());
}
protected function renderContent()
{
$name = $this->getAttribute('name');
$flags = $this->getAttribute('flags');
$label = $this->getAttribute('label', $this->getTranslateClosure($name . '_label'));
$defaultMandatory = $this->getAttribute('mandatory',
isset($this->view['__mandatoryFields'])
&& $this->view['__mandatoryFields'][$this->view->getUniqueId($name)]);
$cssClass = trim(sprintf('TextInput %s %s',
$this->getAttribute('class', ''),
$defaultMandatory === TRUE ? 'mandatory' : ''
));
$content = '';
$attributes = array(
'value' => $this->getAttribute('value', strval($this->view[$name])),
'type' => $this->getAttribute('type', ($flags & \Nethgui\Renderer\WidgetFactoryInterface::TEXTINPUT_PASSWORD) ? 'password' : 'text'),
'placeholder' => $this->getAttribute('placeholder',false),
);
if($this->hasAttribute('htmlName')) {
$attributes['name'] = $this->getAttribute('htmlName');
}
if($this->hasAttribute('type')) {
$cssClass = str_replace('TextInput ', '', $cssClass);
}
$flags = $this->applyDefaultLabelAlignment($flags, \Nethgui\Renderer\WidgetFactoryInterface::LABEL_ABOVE);
if (isset($this->view['__invalidParameters']) && in_array($name, $this->view['__invalidParameters'])) {
$flags |= \Nethgui\Renderer\WidgetFactoryInterface::STATE_VALIDATION_ERROR;
}
$content .= $this->labeledControlTag($label, 'input', $name, $flags, $cssClass, $attributes);
return $content;
}
}