本文整理汇总了PHP中Phalcon\Forms\Element\Text::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::setAttributes方法的具体用法?PHP Text::setAttributes怎么用?PHP Text::setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Forms\Element\Text
的用法示例。
在下文中一共展示了Text::setAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize($menuitems)
{
$this->_action = 'menu';
foreach ($menuitems as $menuItem) {
$name = new Text('menuitem[' . $menuItem->id . '][name]');
$name->setFilters(array('striptags', 'string'));
$name->setAttributes(array('class' => 'form-control'));
$name->setDefault($menuItem->name);
$url = new Text('menuitem[' . $menuItem->id . '][url]');
$url->setFilters(array('striptags', 'string'));
$url->setAttributes(array('class' => 'form-control'));
$url->setDefault($menuItem->url);
$icon = new Text('menuitem[' . $menuItem->id . '][icon]');
$icon->setFilters(array('striptags', 'string'));
$icon->setAttributes(array('class' => 'form-control'));
$icon->setDefault($menuItem->icon);
$device = new Select('menuitem[' . $menuItem->id . '][device]', Devices::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => 'None', 'emptyValue' => 0));
$device->setDefault($menuItem->device_id);
$id = new Hidden('menuitem[' . $menuItem->id . '][id]');
$id->setDefault($menuItem->id);
$this->add($name);
$this->add($url);
$this->add($icon);
$this->add($device);
$this->add($id);
}
}
示例2: initialize
public function initialize()
{
$this->_action = 'menuitem_add';
$name = new Text('name');
$name->setFilters(array('striptags', 'string'));
$name->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off', 'id' => 'menuitem_name'));
$name->setLabel('Name');
$url = new Text('url');
$url->setFilters(array('striptags', 'string'));
$url->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$url->setLabel('URL');
$icon = new Text('icon');
$icon->setFilters(array('striptags', 'string'));
$icon->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$icon->setLabel('Icon');
$device = new Select('device_id', Devices::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => 'None', 'emptyValue' => 0));
$device->setLabel('Device');
$menuId = new Hidden('menu_id');
$menuId->setDefault(1);
$this->add($name);
$this->add($url);
$this->add($icon);
$this->add($device);
$this->add($menuId);
}
示例3: initialize
/**
* Add all fields to the form and set form specific attributes.
*/
public function initialize()
{
$this->_action = 'general';
$title = new Text('title');
$title->setLabel('Title');
$title->setFilters(array('striptags', 'string'));
$title->setAttributes(array('class' => 'form-control'));
$title->setDefault($this->_config->application->title);
$title->addValidators(array(new PresenceOf(array())));
$cryptKey = new Text('cryptkey');
$cryptKey->setLabel('Cryptkey');
$cryptKey->setFilters(array('striptags', 'string'));
$cryptKey->setAttributes(array('class' => 'form-control'));
$cryptKey->setDefault($this->_config->application->phalconCryptKey);
$cryptKey->addValidators(array(new PresenceOf(array())));
$bgcolor = new Select('bgcolor', array('blackbg' => 'Black', 'whitebg' => 'White'), array('useEmpty' => false));
$bgcolor->setLabel('Background color');
$bgcolor->setDefault($this->_config->application->background);
$debug = new Check('debug');
$debug->setLabel('debug');
$debug->setAttributes(array('checked' => $this->_config->application->debug == '1' ? 'checked' : null));
$this->add($title);
$this->add($bgcolor);
$this->add($cryptKey);
$this->add($debug);
}
示例4: initialize
public function initialize()
{
$this->_action = 'devices_add';
$name = new Text('name');
$name->setLabel('Devicename');
$name->setFilters(array('striptags', 'string'));
$name->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$ip = new Text('ip');
$ip->setLabel('IP');
$ip->setFilters(array('striptags', 'string'));
$ip->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$mac = new Text('mac');
$mac->setLabel('MAC');
$mac->setFilters(array('striptags', 'string'));
$mac->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$webtemp = new Text('webtemp');
$webtemp->setLabel('Webtemp path');
$webtemp->setFilters(array('striptags', 'string'));
$webtemp->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off'));
$shutdownMethod = new Select('shutdown_method', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false));
$shutdownMethod->setLabel('Shutdown method');
$showDasboard = new Check('show_on_dashboard');
$showDasboard->setLabel('Show on dashboard');
$showDasboard->setAttributes(array('class' => 'form-control'));
$this->add($name);
$this->add($ip);
$this->add($mac);
$this->add($webtemp);
$this->add($shutdownMethod);
$this->add($showDasboard);
}
示例5: initialize
public function initialize()
{
//username
$username = new Text('login');
$username->setLabel('Login');
$username->addValidator(new PresenceOf(array("message" => "Login required")));
$username->setAttributes(array('id' => 'login-username', 'class' => 'form-control', 'placeholder' => 'username'));
$this->add($username);
//password
$password = new Password('password');
$password->setLabel('Password');
$password->addValidator(new PresenceOf(array("message" => "Password required")));
$password->setAttributes(array('id' => 'login-password', 'class' => 'form-control', 'placeholder' => 'password'));
$password->clear();
$this->add($password);
//remember me
$remember = new Check('remember', array("value" => '1', "id" => "login-remember"));
$remember->setLabel('Remember me');
$this->add($remember);
//CSRF
$csrf = new Hidden('csrf');
$csrf->addValidator(new Identical([$this->security->checkToken() => true, 'message' => 'This request was aborted because it appears to be forged']));
$this->add($csrf);
//Submit
$this->add(new Submit('Sign In', array('class' => 'btn btn-success', 'id' => 'btn-login')));
}
示例6: initialize
public function initialize($config)
{
$title = new Text('title');
$title->setLabel('Title');
$title->setFilters(array('striptags', 'string'));
$title->setAttributes(array('class' => 'form-control'));
$title->setDefault($config->application->title);
$this->add($title);
}
示例7: testFormElementRender
public function testFormElementRender()
{
$element1 = new Text("name");
$element1->setAttributes(array('class' => 'big-input'));
$element2 = new Radio('radio');
$element2->setAttributes(array('value' => 0));
$this->assertEquals('<input type="text" id="name" name="name" class="big-input" />', $element1->render());
$this->assertEquals('<input type="text" id="name" name="name" class="big-input" />', (string) $element1);
$this->assertEquals('<input type="radio" id="radio" name="radio" value="0" />', (string) $element2);
}
示例8: initialize
public function initialize($users)
{
foreach ($users as $user) {
$username = new Text('user[' . $user->id . '][username]');
$username->setLabel('Check device state timeouts');
$username->setFilters(array('striptags', 'string'));
$username->setAttributes(array('class' => 'form-control'));
$username->setDefault($user->username);
$this->add($username);
}
}
示例9: initialize
public function initialize($entity = null, $user_options = array())
{
// Login details
$username = new Element\Text('username');
$username->setLabel('Email');
$username->setFilters(array('striptags', 'trim'));
$username->addValidators(array(new Validator\Email(array('message' => 'This is not a valid email')), new EveValidator\User\Unique(array('message' => 'Email already registered'))));
$username->setAttributes(array('data-toggle' => 'popover', 'data-content' => 'Enter an email address', 'data-title' => 'Help'));
$this->add($username);
$username_again = new Element\Text('username_again');
$username_again->setLabel('Re-enter email');
$username_again->setFilters(array('striptags', 'trim'));
$username_again->addValidators(array(new Validator\Confirmation(array('message' => 'Emails do not match', 'with' => 'username'))));
$this->add($username_again);
$password = new Element\Password('password');
$password->setLabel('Password');
$password->setFilters(array('striptags', 'trim'));
$password->addValidators(array(new Validator\Regex(array('pattern' => '/[A-Za-z\\d\\W]+/i', 'message' => 'Password must be greater than 6 characters')), new Validator\StringLength(array('max' => 100, 'min' => 6, 'messageMaximum' => 'Password is too long', 'messageMinimum' => 'Password is too short'))));
$password->setAttributes(array('data-toggle' => 'popover', 'data-content' => 'Password must be greater than 6 characters', 'data-title' => 'Help'));
$this->add($password);
$password_again = new Element\Password('password_again');
$password_again->setLabel('Re-enter password');
$password_again->setFilters(array('striptags', 'trim'));
$password_again->addValidators(array(new Validator\Confirmation(array('message' => 'Passwords do not match', 'with' => 'password'))));
$this->add($password_again);
$name = new Element\Text('name');
$name->setLabel('Name');
$name->setFilters(array('striptags', 'trim'));
$this->add($name);
$teamspeak = new Element\Text('teamspeak');
$teamspeak->setLabel('Teamspeak');
$teamspeak->setFilters(array('striptags', 'trim'));
$this->add($teamspeak);
$character = new Element\Text('character');
$character->setLabel('Character name');
$character->setFilters(array('striptags', 'trim'));
$character->addValidator(new Validator\PresenceOf(array('message' => 'This field is required')));
$this->add($character);
$game_id = new Element\Text('game_id');
$game_id->setLabel('Character In-Game ID');
$game_id->setFilters(array('striptags', 'trim'));
$game_id->addValidator(new Validator\PresenceOf(array('message' => 'This field is required')));
$this->add($game_id);
$submit = new Element\Submit('submit');
$submit->setLabel('Register');
$submit->setUserOption('icon', 'user');
$submit->setAttribute('value', 'Register');
$submit->setAttribute('class', 'btn btn-primary');
$this->add($submit);
}
示例10: initialize
/**
* Add all fields to the form and set form specific attributes.
*/
public function initialize()
{
$this->_action = $this->config->application->baseUri . 'session/login';
$username = new Text('username');
$username->setLabel('Username');
$username->setFilters(array('striptags', 'string'));
$username->setAttributes(array('placeholder' => 'Username', 'class' => 'form-control' . ($this->_loginFailed ? ' has-error' : null)));
$password = new Password('password');
$password->setLabel('Password');
$password->setFilters(array('striptags', 'string'));
$password->setAttributes(array('placeholder' => 'Password', 'class' => 'form-control' . ($this->_loginFailed ? ' has-error' : null)));
$rememberme = new Check('rememberme');
$rememberme->setLabel('Remember me');
$this->add($username);
$this->add($password);
$this->add($rememberme);
}
示例11: addFIelds
private function addFIelds($device)
{
$name = new Text('devices[' . $device->id . '][name]');
$name->setLabel('Devicename');
$name->setFilters(array('striptags', 'string'));
$name->setAttributes(array('class' => 'form-control'));
$name->setDefault($device->name);
$name->addValidators(array(new PresenceOf(array())));
$ip = new Text('devices[' . $device->id . '][ip]');
$ip->setLabel('IP');
$ip->setFilters(array('striptags', 'string'));
$ip->setAttributes(array('class' => 'form-control'));
$ip->setDefault($device->ip);
$ip->addValidator(new Regex(array('pattern' => '/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/')));
$mac = new Text('devices[' . $device->id . '][mac]');
$mac->setLabel('MAC');
$mac->setFilters(array('striptags', 'string'));
$mac->setAttributes(array('class' => 'form-control'));
$mac->setDefault($device->mac);
$mac->addValidator(new Regex(array('pattern' => '/^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/')));
$webtemp = new Text('devices[' . $device->id . '][webtemp]');
$webtemp->setLabel('Webtemp path');
$webtemp->setFilters(array('striptags', 'string'));
$webtemp->setAttributes(array('class' => 'form-control'));
$webtemp->setDefault($device->webtemp);
$shutdownMethod = new Select('devices[' . $device->id . '][shutdown_method]', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false));
$shutdownMethod->setDefault($device->shutdown_method);
$showDasboard = new Check('devices[' . $device->id . '][show_on_dashboard]');
$showDasboard->setLabel('Show on dashboard');
$showDasboard->setFilters(array('striptags', 'int'));
$showDasboard->setAttributes(array('class' => 'form-control'));
$showDasboard->setDefault($device->show_on_dashboard);
$id = new Hidden('devices[' . $device->id . '][id]');
$id->setDefault($device->id);
$this->add($name);
$this->add($ip);
$this->add($mac);
$this->add($webtemp);
$this->add($shutdownMethod);
$this->add($showDasboard);
$this->add($id);
}
示例12: testFormOptions
public function testFormOptions()
{
$this->specify("Text elements don't properly store user options or attributes", function () {
$element1 = new Text("name");
$element1->setAttributes(array('class' => 'big-input'));
$element1->setUserOptions(array('some' => 'value'));
expect($element1->getUserOptions())->equals(array('some' => 'value'));
expect($element1->getUserOption('some'))->equals('value');
expect($element1->getUserOption('some-non'))->null();
expect($element1->getUserOption('some-non', 'default'))->equals('default');
});
}
示例13: initialize
/**
* Add all fields to the form and set form specific attributes.
*/
public function initialize()
{
$this->_action = 'dashboard';
$devicestateTimeouts = new Text('check-devicestate-interval');
$devicestateTimeouts->setLabel('Check device state interval');
$devicestateTimeouts->setFilters(array('striptags', 'int'));
$devicestateTimeouts->setAttributes(array('class' => 'form-control'));
$devicestateTimeouts->setDefault($this->_config->dashboard->checkDeviceStatesInterval);
$devicestateTimeouts->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$alertTimeout = new Text('alert-timeout');
$alertTimeout->setLabel('Alert timeout');
$alertTimeout->setFilters(array('striptags', 'int'));
$alertTimeout->setAttributes(array('class' => 'form-control'));
$alertTimeout->setDefault($this->_config->dashboard->alertTimeout);
$alertTimeout->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$phpSysInfoURL = new Text('phpsysinfo-url');
$phpSysInfoURL->setLabel('PHPSysInfo URL');
$phpSysInfoURL->setFilters(array('striptags', 'string'));
$phpSysInfoURL->setAttributes(array('class' => 'form-control'));
$phpSysInfoURL->setDefault($this->_config->dashboard->phpSysInfoURL);
$phpSysInfoVCore = new Text('phpsysinfo-vcore');
$phpSysInfoVCore->setLabel('PHPSysInfo vcore label');
$phpSysInfoVCore->setFilters(array('striptags', 'string'));
$phpSysInfoVCore->setAttributes(array('class' => 'form-control'));
$phpSysInfoVCore->setDefault($this->_config->dashboard->phpSysInfoVCore);
$transmissionURL = new Text('transmission-url');
$transmissionURL->setLabel('Transmission URL');
$transmissionURL->setFilters(array('striptags', 'string'));
$transmissionURL->setAttributes(array('class' => 'form-control'));
$transmissionURL->setDefault($this->_config->dashboard->transmissionURL);
$transmissionUsername = new Text('transmission-username');
$transmissionUsername->setLabel('Transmission username');
$transmissionUsername->setFilters(array('striptags', 'string'));
$transmissionUsername->setAttributes(array('class' => 'form-control'));
$transmissionUsername->setDefault($this->_config->dashboard->transmissionUsername);
$transmissionPassword = new Password('transmission-password');
$transmissionPassword->setLabel('Transmission password');
$transmissionPassword->setFilters(array('striptags', 'string'));
$transmissionPassword->setAttributes(array('class' => 'form-control'));
$transmissionPassword->setDefault($this->_config->dashboard->transmissionPassword);
$transmissionInterval = new Text('transmission-update-interval');
$transmissionInterval->setLabel('Transmission update inteval');
$transmissionInterval->setFilters(array('striptags', 'int'));
$transmissionInterval->setAttributes(array('class' => 'form-control'));
$transmissionInterval->setDefault($this->_config->dashboard->transmissionUpdateInterval);
$transmissionInterval->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$rotateMoviesInterval = new Text('rotate-movies-interval');
$rotateMoviesInterval->setLabel('Rotate movies inteval');
$rotateMoviesInterval->setFilters(array('striptags', 'int'));
$rotateMoviesInterval->setAttributes(array('class' => 'form-control'));
$rotateMoviesInterval->setDefault($this->_config->dashboard->rotateMoviesInterval);
$rotateMoviesInterval->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$rotateEpisodesInterval = new Text('rotate-episodes-interval');
$rotateEpisodesInterval->setLabel('Rotate episode inteval');
$rotateEpisodesInterval->setFilters(array('striptags', 'int'));
$rotateEpisodesInterval->setAttributes(array('class' => 'form-control'));
$rotateEpisodesInterval->setDefault($this->_config->dashboard->rotateEpisodesInterval);
$rotateEpisodesInterval->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$rotateAlbumsInterval = new Text('rotate-albums-interval');
$rotateAlbumsInterval->setLabel('Rotate albums inteval');
$rotateAlbumsInterval->setFilters(array('striptags', 'int'));
$rotateAlbumsInterval->setAttributes(array('class' => 'form-control'));
$rotateAlbumsInterval->setDefault($this->_config->dashboard->rotateAlbumsInterval);
$rotateAlbumsInterval->addValidator(new Regex(array('pattern' => '/^[0-9]+$/', 'message' => 'Not a number')));
$this->add($devicestateTimeouts);
$this->add($alertTimeout);
$this->add($phpSysInfoURL);
$this->add($phpSysInfoVCore);
$this->add($transmissionURL);
$this->add($transmissionUsername);
$this->add($transmissionPassword);
$this->add($transmissionInterval);
$this->add($rotateMoviesInterval);
$this->add($rotateEpisodesInterval);
$this->add($rotateAlbumsInterval);
}
示例14: testIssue2045
public function testIssue2045()
{
$element = new \Phalcon\Forms\Element\Text("name");
$element->setAttributes(array('class' => 'big-input'));
$element->setAttribute("id", NULL);
$this->assertEquals('<input type="text" name="name" class="big-input" />', $element->render());
}
示例15: testFormElementRender
public function testFormElementRender()
{
$element1 = new Text("name");
$element1->setAttributes(array('class' => 'big-input'));
$this->assertEquals($element1->render(), '<input class="big-input" name="name" id="name" value="" type="text" />');
$this->assertEquals((string) $element1, '<input class="big-input" name="name" id="name" value="" type="text" />');
}