本文整理汇总了PHP中Nette\Forms\Container::addText方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::addText方法的具体用法?PHP Container::addText怎么用?PHP Container::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Container
的用法示例。
在下文中一共展示了Container::addText方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentGrid
/**
* @return \Nextras\Datagrid\Datagrid
*/
protected function createComponentGrid()
{
$grid = new MyDatagrid();
$grid->setTranslator($this->translator);
$grid->setShowCheckboxes(FALSE);
$grid->addColumn('login', 'Uživatel')->enableSort();
$grid->addColumn('ip', 'IP adresa')->enableSort();
$grid->addColumn('message', 'Zpráva')->enableSort();
$grid->addColumn('timestamp', 'Datum a čas')->enableSort();
$grid->setRowPrimaryKey('syslogID');
$model = $this->historyRepository;
$grid->setColumnGetterCallback(function ($row, $column) {
$getter = "get" . ucfirst($column);
return $row->{$getter}();
});
$grid->setDatasourceCallback(function ($filter, $order, $paginator) use($model) {
$data = $model->read($paginator)->select("syslog.*, user.login, user.ip AS loginIP");
foreach ($filter as $k => $v) {
$k = str_replace("login", "user.login", $k);
$k = str_replace("ip", "syslog.ip", $k);
$data->where($k . " LIKE ?", "%" . $v . "%");
}
if ($order) {
$order = str_replace("login", "user.login", implode(" ", $order));
$order = str_replace("ip", "syslog.ip", $order);
$data->order($order);
} else {
$data->order("timestamp DESC");
}
return $data;
});
$grid->setPagination(10, function ($filter) use($model) {
$data = $model->read();
foreach ($filter as $k => $v) {
$k = str_replace("login", "user.login", $k);
$k = str_replace("ip", "syslog.ip", $k);
$data->where($k . " LIKE ?", "%" . $v . "%");
}
return $data->count('*');
});
$grid->setFilterFormFactory(function () {
$form = new Container();
$form->addText("login", "Uživatel");
$form->addText("ip", "IP adresa");
$form->addText("message", "Zpráva");
// these buttons are not compulsory
$form->addSubmit('filter', 'Filtrovat')->getControlPrototype()->class = 'btn btn-primary';
$form->addSubmit('cancel', 'Storno')->getControlPrototype()->class = 'btn btn-default';
return $form;
});
return $grid;
}
示例2: addToFormContainer
/**
* Adds text field to filter form
* @param Nette\Forms\Container $container
*/
public function addToFormContainer($container)
{
$container->addText($this->key, $this->name);
if ($this->getPlaceholder()) {
$container[$this->key]->setAttribute('placeholder', $this->getPlaceholder());
}
}
示例3: addToFormContainer
/**
* Adds select box to filter form
* @param Nette\Forms\Container $container
*/
public function addToFormContainer($container)
{
$container->addText($this->key, $this->name)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true');
if ($this->getPlaceholder()) {
$container[$this->key]->setAttribute('placeholder', $this->getPlaceholder());
}
}
示例4: addToFormContainer
/**
* Get assambled form
* @param Nette\Forms\Container $container
* @return void
*/
public function addToFormContainer($container)
{
/** @var Nette\Application\UI\Form $form */
$form = $container->lookup('Nette\\Application\\UI\\Form');
$translator = $form->getTranslator();
$main_options = [];
/**
* First foreach for filling "main" select
*/
foreach ($this->group_actions as $id => $action) {
$main_options[$id] = $action->getTitle();
}
$container->addSelect('group_action', '', $main_options)->setPrompt('ublaboo_datagrid.choose');
/**
* Second for creating select for each "sub"-action
*/
foreach ($this->group_actions as $id => $action) {
$control = NULL;
if ($action instanceof GroupSelectAction) {
if ($action->hasOptions()) {
$control = $container->addSelect($id, '', $action->getOptions());
$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id);
}
} else {
if ($action instanceof GroupTextAction) {
$control = $container->addText($id, '');
$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id)->addConditionOn($container['group_action'], Form::EQUAL, $id)->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'))->endCondition();
} else {
if ($action instanceof GroupTextareaAction) {
$control = $container->addTextarea($id, '');
$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id)->addConditionOn($container['group_action'], Form::EQUAL, $id)->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'));
}
}
}
if ($control) {
/**
* User may set a class to the form control
*/
if ($class = $action->getClass()) {
$control->setAttribute('class', $class);
}
/**
* User may set additional attribtues to the form control
*/
foreach ($action->getAttributes() as $name => $value) {
$control->setAttribute($name, $value);
}
}
}
foreach ($this->group_actions as $id => $action) {
$container['group_action']->addCondition(Form::EQUAL, $id)->toggle(static::ID_ATTRIBUTE_PREFIX . $id);
}
$container['group_action']->addCondition(Form::FILLED)->toggle(strtolower($this->datagrid->getName()) . 'group_action_submit');
$container->addSubmit('submit', 'ublaboo_datagrid.execute')->setAttribute('id', strtolower($this->datagrid->getName()) . 'group_action_submit');
if ($form instanceof Nette\ComponentModel\IComponent) {
$form->onSubmit[] = [$this, 'submitted'];
}
}
示例5: addToFormContainer
/**
* Adds select box to filter form
* @param Nette\Forms\Container $container
*/
public function addToFormContainer(Nette\Forms\Container $container)
{
$container->addText($this->key, $this->name)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true');
$this->addAttributes($container[$this->key]);
if ($this->grid->hasAutoSubmit()) {
$container[$this->key]->setAttribute('data-autosubmit-change', TRUE);
}
if ($this->getPlaceholder()) {
$container[$this->key]->setAttribute('placeholder', $this->getPlaceholder());
}
}
示例6: generateForm
public function generateForm(Items\Base $item, Nette\Forms\Container &$formContainer, $name, $parentName, $togglingObject, array $userOptions = [])
{
$input = $formContainer->addText($name, $name);
$input->setOption('id', $parentName . '__' . $name);
$input->setValue($item->getContent());
$input->setType('time');
$input->addCondition(UI\Form::FILLED)->addRule(UI\Form::PATTERN, __('Time must be in format HH:MM'), '([0-9]{2}[-: ]{1}[0-9]{2})');
if (!is_null($togglingObject)) {
$togglingObject->toggle($input->getOption('id'));
}
$item->applyUserOptions($input, $userOptions);
}
示例7: getFormContainer
public function getFormContainer()
{
$container = new Container();
$container->addText('openid_identifier', 'OpenID');
return $container;
}
示例8: createInput
/**
* @param Container $form
* @return \Nette\Forms\IControl|NULL
* @throws Exception
*/
public function createInput(Container $form)
{
$name = $this->getName();
$input = NULL;
$items = [];
if ($options = (array) $this->getValue('options')) {
foreach ($options as $key => $option) {
$items[$key] = $option['option'];
}
}
switch ($this->type) {
case 'text':
$input = $form->addText($name);
break;
case 'textarea':
$input = $form->addTextArea($name);
break;
case 'radio':
$input = $form->addRadioList($name, NULL, $items);
break;
case 'checkbox':
$input = $form->addCheckboxList($name, NULL, $items);
break;
case 'select':
if ($this->getValue('multiple')) {
$input = $form->addMultiSelect($name)->setItems($items, FALSE);
}
if (!$this->getValue('multiple')) {
$input = $form->addSelect($name)->setItems($items, FALSE);
}
break;
default:
throw new \Exception();
}
if ($this->getValue('isRequired') && isset($input)) {
$input->setRequired(TRUE);
}
return $input;
}
示例9: configureOptionsContainer
/**
* @param Container $container
* @return Container
*/
public function configureOptionsContainer(Container $container)
{
$container->addText('token', 'Token');
return $container;
}
示例10: createComponentGridAction
/**
* @return MyDatagrid
*/
protected function createComponentGridAction()
{
$grid = new MyDatagrid();
$grid->setTranslator($this->translator);
$grid->setShowCheckboxes(TRUE);
$grid->addColumn('name', 'Jméno akce')->enableSort();
$grid->addColumn('humanName', 'Lidský formát')->enableSort();
$grid->addCellsTemplate(APP_DIR . "/templates/" . $this->getName() . "/action-row-actions.latte");
$grid->setRowPrimaryKey('aclActionID');
$model = $this->actionRepository;
$grid->setDatasourceCallback(function ($filter, $order, $paginator) use($model) {
$data = $model->read($paginator);
foreach ($filter as $k => $v) {
$data->where($k . " LIKE ?", "%" . $v . "%");
}
if ($order) {
$data->order(implode(" ", $order));
}
return $data;
});
$grid->setPagination(10, function ($filter) use($model) {
$data = $model->read();
foreach ($filter as $k => $v) {
$data->where($k . " LIKE ?", "%" . $v . "%");
}
return $data->count('*');
});
$grid->setFilterFormFactory(function () {
$form = new Container();
$form->addText("name", "Jméno akce");
$form->addText("humanName", "Jméno akce - lidský formát");
// these buttons are not compulsory
$form->addSubmit('filter', 'Filtrovat')->getControlPrototype()->class = 'btn btn-primary';
$form->addSubmit('cancel', 'Storno')->getControlPrototype()->class = 'btn';
return $form;
});
return $grid;
}
示例11: createComponentGrid
/** Vytvoří komponentu gridu
*
*/
protected function createComponentGrid()
{
$grid = new MyDatagrid();
$grid->setTranslator($this->translator);
$grid->setShowCheckboxes(TRUE);
$grid->addColumn('login', 'Uživatelské jméno')->enableSort();
$grid->addColumn('roleName', 'Skupina')->enableSort();
$grid->addColumn('active', 'Aktivní')->enableSort();
$grid->addColumn('lastLogged', 'Poslední přihlášení')->enableSort();
$grid->addColumn('ip', 'IP adresa')->enableSort();
$grid->addCellsTemplate(APP_DIR . "/templates/" . $this->getName() . "/row-actions.latte");
$grid->setRowPrimaryKey('userID');
$model = $this->userRepository;
$user = $this->user;
$grid->setDatasourceCallback(function ($filter, $order, $paginator) use($model, $user) {
if ($user->isInRole("root")) {
$data = $model->read($paginator);
} else {
$data = $model->read($paginator)->where("login != ?", "root")->where("userID = ? OR user.aclRoleID != ?", array($user->getId(), $user->getIdentity()->data['aclRoleID']));
}
foreach ($filter as $k => $v) {
$k = str_replace("roleName", "role.name", $k);
$data->where($k . " LIKE ?", "%" . $v . "%");
}
if ($order) {
$order = str_replace("roleName", "role.name", implode(" ", $order));
$data->order($order);
}
// Role name hacking
foreach ($data as $entity) {
$entity->setRoleName($entity->getRole()->getName());
}
return $data;
});
$grid->setPagination(10, function ($filter) use($model) {
$data = $model->read();
foreach ($filter as $k => $v) {
$k = str_replace("roleName", "role.name", $k);
$data->where($k . " LIKE ?", "%" . $v . "%");
}
return $data->count('*');
});
$roleModel = $this->roleRepository;
$grid->setFilterFormFactory(function () use($roleModel) {
$form = new Container();
$form->addText("login", "Uživatelské jméno");
$form->addSelect("roleName", "Skupina", $roleModel->read()->fetchPairs("name", "name"))->setPrompt("Vše");
$form->addSelect("active", "Aktivní", array("0" => "Neaktivní", "1" => "Aktivní"))->setPrompt("Vše");
$form->addText("lastLogged", "Poslední přihlášení");
$form->addText("ip", "IP adresa");
// these buttons are not compulsory
$form->addSubmit('filter', 'Filtrovat')->getControlPrototype()->class = 'btn btn-primary';
$form->addSubmit('cancel', 'Storno')->getControlPrototype()->class = 'btn';
return $form;
});
return $grid;
}
示例12: addTime
public static function addTime(Nette\Forms\Container $container, $name, $label = NULL, $cols = NULL, $maxLength = NULL, \DateTime $dateTime = NULL, $onNullSetNow = FALSE)
{
$input = $container->addText($name, $label, $cols, $maxLength);
$input->setType('time');
$input->addCondition(UI\Form::FILLED)->addRule(UI\Form::PATTERN, static::$useTranslatorRule ? __('Time must be in format HH:MM') : $name . '.' . static::$translatorRuleClass . '.filled', '([01]?[0-9]{1}|2[0-3]{1})(:[0-5]{1}[0-9]{1}){1,2}');
if ($onNullSetNow && is_null($dateTime)) {
$dateTime = new Nette\Utils\DateTime();
}
if (!is_null($dateTime)) {
$input->setDefaultValue($dateTime->format('H:i:s'));
}
return $input;
}