本文整理汇总了PHP中Phalcon\Forms\Element\Text::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::setDefault方法的具体用法?PHP Text::setDefault怎么用?PHP Text::setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Forms\Element\Text
的用法示例。
在下文中一共展示了Text::setDefault方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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($entity = null, $options = null)
{
$city = new Select('cityid', City::find(), array('using' => array('id', 'city'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione una Ciudad')));
$city->setLabel('Ciudad');
$this->add($city);
$township = new Text('township');
$township->setLabel('Sector');
$this->add($township);
$countryvalue = "";
$statevalue = "";
$city = "";
if (isset($entity)) {
if ($entity->getCity()) {
$countryvalue = $entity->getCity()->getCountry()->getCountry();
$statevalue = $entity->getCity()->getState()->getState();
}
}
$country = new Text('country');
$country->setLabel('País');
$country->setDefault($countryvalue);
$this->add($country);
$state = new Text('state');
$state->setDefault($statevalue);
$state->setLabel('Estado');
$this->add($state);
}
示例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: clearFormElements
/**
* Tests clearing the Form Elements
*
* @issue 12165
* @issue 12099
* @author Serghei Iakovlev <serghei@phalconphp.com>
* @since 2016-10-01
* @param IntegrationTester $I
*/
public function clearFormElements(IntegrationTester $I)
{
$pass = new Password('passwd');
$eml = new Email('email');
$text = new Text('name');
$text->setDefault('Serghei Iakovlev');
$form = new Form();
$form->add($eml)->add($text)->add($pass);
$I->assertNull($form->get('passwd')->getValue());
$I->assertEquals('Serghei Iakovlev', $form->get('name')->getValue());
$I->assertEquals('<input type="password" id="passwd" name="passwd">', $form->render('passwd'));
$I->assertEquals('<input type="email" id="email" name="email">', $form->render('email'));
$I->assertEquals('<input type="text" id="name" name="name" value="Serghei Iakovlev">', $form->render('name'));
$_POST = ['passwd' => 'secret', 'name' => 'Andres Gutierrez'];
$I->assertEquals('secret', $form->get('passwd')->getValue());
$I->assertEquals($pass->getValue(), $form->get('passwd')->getValue());
$I->assertEquals('Andres Gutierrez', $form->get('name')->getValue());
$I->assertEquals('<input type="password" id="passwd" name="passwd" value="secret">', $form->render('passwd'));
$I->assertEquals('<input type="text" id="name" name="name" value="Andres Gutierrez">', $form->render('name'));
Tag::setDefault('email', 'andres@phalconphp.com');
$I->assertEquals('<input type="email" id="email" name="email" value="andres@phalconphp.com">', $form->render('email'));
$I->assertEquals('andres@phalconphp.com', $form->get('email')->getValue());
$pass->clear();
$I->assertEquals('<input type="password" id="passwd" name="passwd">', $form->render('passwd'));
$I->assertNull($pass->getValue());
$I->assertEquals($pass->getValue(), $form->get('passwd')->getValue());
$form->clear();
$I->assertEquals('Serghei Iakovlev', $form->get('name')->getValue());
$I->assertNull($form->get('email')->getValue());
$I->assertEquals('<input type="text" id="name" name="name" value="Serghei Iakovlev">', $form->render('name'));
$I->assertEquals('<input type="email" id="email" name="email">', $form->render('email'));
$I->assertEquals(['passwd' => 'secret', 'name' => 'Andres Gutierrez'], $_POST);
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: initialize
/**
* Siempre viene la entidad por parametro.
* si viene un $options['remito_id'] es un editar y buscamos el contenido en la bd
* @param null $entity
* @param array $options
*/
public function initialize($entity = null, $options = array())
{
/*=========================== COLUMNA EXTRA =====================================*/
if ($entity != null) {
$columnas = $entity;
foreach ($columnas as $col) {
$elemento = new Text($col->getColumnaClave(), array('placeholder' => 'Ingrese ' . $col->getColumnaNombre(), 'class' => 'form-control', 'maxlength' => 60));
$elemento->setLabel($col->getColumnaNombre());
//Buscamos el contenido para el edit.
if (isset($options['remito_id'])) {
$remito_id = $options['remito_id'];
$contenidoExtra = Contenidoextra::findFirst(array('contenidoExtra_remitoId = :remito_id: AND
contenidoExtra_columnaId=:columna_id:', 'bind' => array('remito_id' => $remito_id, 'columna_id' => $col->getColumnaId())));
if ($contenidoExtra) {
$elemento->setDefault($contenidoExtra->getContenidoExtraDescripcion());
}
}
$this->add($elemento);
}
}
}
示例9: initialize
public function initialize($entity = null, $options = null)
{
if (isset($options['edit']) && $options['edit'] === true) {
$this->edit = true;
}
// First name
$user_first_name = new Text('user_first_name', array('placeholder' => 'First name'));
$user_first_name->addValidators(array(new PresenceOf(array('message' => 'First name is required'))));
$this->add($user_first_name);
// Last name
$user_last_name = new Text('user_last_name', array('placeholder' => 'Last name'));
$user_last_name->addValidators(array(new PresenceOf(array('message' => 'Last name is required'))));
$this->add($user_last_name);
// Email
$user_email = new Text('user_email', array('placeholder' => 'Email'));
$user_email->addValidators(array(new PresenceOf(array('message' => 'The e-mail is required')), new Email(array('message' => 'The e-mail is not valid'))));
$this->add($user_email);
//Password
$user_password = new Password('user_password', array('placeholder' => 'Password'));
$user_password->addValidators(array(new PresenceOf(array('message' => 'Password is required')), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters'))));
$this->add($user_password);
// User is active
$this->add(new Select('user_is_active', array(1 => 'Yes', 0 => 'No')));
// User location
$user_profile_location = new Text('user_profile_location', array('placeholder' => 'Location'));
if (true === $this->edit) {
$user_profile_location->setDefault($entity->profile->getUserProfileLocation());
}
$this->add($user_profile_location);
// User role
// We query the acl_roles table for all existing roles and add the to the select element
$user_acl_role = new Select('user_acl_role', AclRoles::find(), array('using' => array('name', 'name')));
$this->add($user_acl_role);
//CSRF
$csrf = new Hidden('csrf');
$csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
$this->add($csrf);
$this->add(new Submit('save', array('class' => 'btn btn-lg btn-primary btn-block')));
}
示例10: initialize
public function initialize($entity = null, $options = null)
{
$city = new Select('cityid', City::find(), array('using' => array('id', 'city'), 'useEmpty' => TRUE, 'emptyText' => 'Seleccione una Ciudad'));
$city->setLabel('Ciudad');
$this->add($city);
//var_dump($entity->townshipid);
if (isset($entity)) {
$township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township')));
$township->setLabel('Sector');
$this->add($township);
} else {
$township = new Select('townshipid', array(), array('useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un Sector')));
$township->setLabel('Sector');
$this->add($township);
}
$countryvalue = "";
$statevalue = "";
$city = "";
if (isset($entity)) {
if ($entity->getCity()) {
$countryvalue = $entity->getCity()->getCountry()->getCountry();
$statevalue = $entity->getCity()->getState()->getState();
}
}
$country = new Text('country');
$country->setLabel('País');
$country->setDefault($countryvalue);
$this->add($country);
$state = new Text('state');
$state->setDefault($statevalue);
$state->setLabel('Estado');
$this->add($state);
$neighborhood = new Text('neighborhood');
$neighborhood->setLabel('Barrio');
$this->add($neighborhood);
//añadimos un botón de tipo submit
$submit = $this->add(new Submit('Guardar', array('class' => 'btn btn-success')));
}
示例11: 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);
}
示例12: initialize
public function initialize($obj = null, $options = array())
{
$detalhes = unserialize($this->ecommerce_options->produto_detalhe_options);
foreach ($detalhes as $key => $value) {
$chave = $key;
$chave = new Select("detalhes[{$value['label']}][]", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome')));
$chave->setLabel($value['label']);
$chave->setAttribute('class', 'form-control ' . $value['label']);
if (!is_null($obj)) {
$chave->setDefault($obj->{$value}['label']);
}
$this->add($chave);
}
#Input Valor
$valor = new Text("detalhes[valor][]");
$valor->setLabel("valor");
$valor->setAttribute('class', 'form-control money');
if (!is_null($obj)) {
$valor->setDefault($obj->valor);
}
$this->add($valor);
#Input desconto
$desconto = new Text("detalhes[desconto][]");
$desconto->setLabel("desconto");
$desconto->setAttribute('class', 'form-control money');
if (!is_null($obj)) {
$desconto->setDefault($obj->desconto);
}
$this->add($desconto);
#Input Estoque
$estoque = new Numeric("detalhes[estoque][]");
$estoque->setLabel("estoque");
$estoque->setAttribute('class', 'form-control');
$this->add($estoque);
if (!is_null($obj)) {
$estoque->setDefault($obj->estoque);
}
if ($this->ecommerce_options->produto_cubagem_detalhe == '1') {
$peso = new Numeric("detalhes[peso][]");
$peso->setLabel("peso");
$peso->setAttribute('class', 'form-control');
if (!is_null($obj)) {
$peso->setDefault($obj->peso);
}
$this->add($peso);
$altura = new Numeric("detalhes[altura][]");
$altura->setLabel("altura");
$altura->setAttribute('class', 'form-control');
$this->add($altura);
if (!is_null($obj)) {
$altura->setDefault($obj->altura);
}
$largura = new Numeric("detalhes[largura][]");
$largura->setLabel("largura");
$largura->setAttribute('class', 'form-control');
$this->add($largura);
if (!is_null($obj)) {
$largura->setDefault($obj->largura);
}
$comprimento = new Numeric("detalhes[comprimento][]");
$comprimento->setLabel("comprimento");
$comprimento->setAttribute('class', 'form-control');
$this->add($comprimento);
if (!is_null($obj)) {
$comprimento->setDefault($obj->comprimento);
}
}
if (!is_null($obj)) {
$detalhe_id = new hidden("detalhes[detalhe_id][]");
$detalhe_id->setAttribute('class', 'form-control detalhe_id dynamicId');
$detalhe_id->setDefault($obj->detalhe_id);
$this->add($detalhe_id);
}
}