本文整理匯總了PHP中Nette\Forms\Container::addSubmit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::addSubmit方法的具體用法?PHP Container::addSubmit怎麽用?PHP Container::addSubmit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Forms\Container
的用法示例。
在下文中一共展示了Container::addSubmit方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
/**
* Get assambled form
* @param Nette\Forms\Container $group_action_container
* @param Form $form
* @param Nette\Localization\ITranslator $translator
* @return void
*/
public function addToFormContainer($group_action_container, $form, $translator = NULL)
{
/**
* First foreach for filling "main" select
*/
foreach ($this->group_actions as $id => $action) {
$main_options[$id] = $action->getTitle();
}
$group_action_container->addSelect('group_action', '', $main_options)->setPrompt($translator ? $translator->translate('Choose') : 'Choose');
/**
* Second for creating select for each "sub"-action
*/
foreach ($this->group_actions as $id => $action) {
if ($action->hasOptions()) {
$group_action_container->addSelect($id, '', $action->getOptions())->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id);
}
}
foreach ($this->group_actions as $id => $action) {
$group_action_container['group_action']->addCondition(Form::EQUAL, $id)->toggle(static::ID_ATTRIBUTE_PREFIX . $id);
}
$group_action_container['group_action']->addCondition(Form::FILLED)->toggle('group_action_submit');
$group_action_container->addSubmit('submit', $translator ? $translator->translate('Do') : 'Do')->setAttribute('id', 'group_action_submit');
$form->onSubmit[] = [$this, 'submitted'];
}
示例3: 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($translator->translate('ublaboo_datagrid.choose'));
/**
* Second for creating select for each "sub"-action
*/
foreach ($this->group_actions as $id => $action) {
if ($action instanceof GroupSelectAction) {
if ($action->hasOptions()) {
$container->addSelect($id, '', $action->getOptions())->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id);
}
} else {
if ($action instanceof GroupTextAction) {
$container->addText($id, '')->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id)->addConditionOn($container['group_action'], Form::EQUAL, $id)->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'));
}
}
}
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('group_action_submit');
$container->addSubmit('submit', $translator->translate('ublaboo_datagrid.execute'))->setAttribute('id', 'group_action_submit');
if ($form instanceof Nette\ComponentModel\IComponent) {
$form->onSubmit[] = [$this, 'submitted'];
}
}
示例4: 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;
}
示例5: 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;
}