本文整理汇总了PHP中Venne\Forms\Form::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getForm方法的具体用法?PHP Form::getForm怎么用?PHP Form::getForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Venne\Forms\Form
的用法示例。
在下文中一共展示了Form::getForm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
/**
* @param Form $form
*/
public function configure(Form $form)
{
$form->addGroup();
$form->addText('name', 'Name');
$form->addText('localUrl', 'URL');
$form->addText('title', 'Title');
$form->addText('keywords', 'Keywords');
$form->addText('description', 'Description');
$form->addManyToOne('author', 'Author');
$form->addSelect('robots', 'Robots')->setItems(RouteEntity::getRobotsValues(), FALSE);
$form->addSelect('changefreq', 'Change frequency')->setItems(RouteEntity::getChangefreqValues(), FALSE)->setPrompt('-------');
$form->addSelect('priority', 'Priority')->setItems(RouteEntity::getPriorityValues(), FALSE)->setPrompt('-------');
// layout
$form->setCurrentGroup($form->addGroup());
$form->addCheckbox('copyLayoutFromParent', 'Layout from parent');
$form['copyLayoutFromParent']->addCondition($form::EQUAL, FALSE)->toggle('group-layout_' . $form->data->id);
$form->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout_' . $form->data->id));
$form->addManyToOne('layout', 'Layout');
$form->setCurrentGroup($form->addGroup());
$form->addCheckbox('copyLayoutToChildren', 'Share layout with children');
$form['copyLayoutToChildren']->addCondition($form::EQUAL, FALSE)->toggle('group-layout2_' . $form->data->id);
$form->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout2_' . $form->data->id));
$form->addManyToOne('childrenLayout', 'Share new layout');
// cache
$form->setCurrentGroup($form->addGroup());
$form->addCheckbox('copyCacheModeFromParent', 'Cache mode from parent');
$form['copyCacheModeFromParent']->addCondition($form::EQUAL, FALSE)->toggle('group-cache_' . $form->data->id);
$form->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-cache_' . $form->data->id));
$form->addSelect('cacheMode', 'Cache strategy')->setItems(\CmsModule\Content\Entities\RouteEntity::getCacheModes(), FALSE)->setPrompt('off');
$form->setCurrentGroup($form->addGroup());
$form->addFileEntityInput('photo', 'Photo');
$form->addTextArea('notation', 'Notation');
$form->addTextArea('text', 'Text');
$form->addGroup('Dates');
$form->addDateTime('created', 'Created')->setDisabled(TRUE);
$form->addDateTime('updated', 'Updated')->setDisabled(TRUE);
$form->addDateTime('released', 'Released')->addRule($form::FILLED);
$form->addDateTime('expired', 'Expired');
$form->addGroup('Tags');
$form->addContentTags('tags');
$aliases = $form->addMany('aliases', function (\Venne\Forms\Container $container) use($form) {
$container->setCurrentGroup($form->addGroup('URL alias'));
$container->addText('aliasUrl', 'Url')->setRequired();
$container->addText('aliasLang', 'Language alias');
$container->addText('aliasDomain', 'Domain url');
$container->addSubmit('remove', 'Remove alias')->addRemoveOnClick();
});
$aliases->addSubmit('add', 'Add alias')->addCreateOnClick();
$form->setCurrentGroup();
$form->addSaveButton('Save');
}
示例2: configure
/**
* @param Form $form
*/
public function configure(Form $form)
{
$infoGroup = $form->addGroup('Informations');
// route
$page = $form->addOne('page');
$mainRoute = $page->addOne('mainRoute');
$mainRoute->setCurrentGroup($infoGroup);
$name = $mainRoute->addText('name', 'Name');
if (!$form->data->page->mainRoute->locale) {
$name->addRule($form::FILLED);
}
$mainRoute->addHidden('localUrlTemplate')->getControlPrototype()->class[] = 'localUrlTemplate';
$input = \Nette\Utils\Html::el('input');
$input->id = 'form-checkbox';
$input->type = 'checkbox';
$htmlUrl = \Nette\Utils\Html::el('span');
$htmlUrl->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>');
$input = \Nette\Utils\Html::el('input');
$input->id = 'form-checkbox-title';
$input->type = 'checkbox';
$htmlTitle = \Nette\Utils\Html::el('span');
$htmlTitle->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>');
$input = \Nette\Utils\Html::el('input');
$input->id = 'form-checkbox-navigationTitle';
$input->type = 'checkbox';
$htmlNavigation = \Nette\Utils\Html::el('span');
$htmlNavigation->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>');
$mainRoute->addText('localUrl', 'URL')->addRule($form::REGEXP, "URL can not contain '/'", "/^[a-zA-z0-9._-]*\$/");
$mainRoute['localUrl']->setOption('description', $htmlUrl)->getControlPrototype()->class[] = 'localUrl';
if (!$form->data->page->mainRoute->locale) {
$mainRoute['localUrl']->addRule($form::FILLED);
}
$mainRoute->setCurrentGroup($group = $form->addGroup());
$mainRoute->addText('title', 'Title')->setOption('description', $htmlTitle)->getControlPrototype()->class[] = 'formTitle';
$page->setCurrentGroup($group);
$navigationTitle = $page->addText('navigationTitle', 'Navigation title')->setOption('description', $htmlNavigation);
$navigationTitle->getControlPrototype()->class[] = 'formNavigation';
if (!$form->data->page->mainRoute->locale) {
$navigationTitle->addRule($form::FILLED);
}
if ($form->data->page->parent) {
/** @var ManyToOne $parent */
$parent = $page->addManyToOne('parent', 'Parent');
$parent->setQuery($this->getPagesQueryBuilder($form->data->page))->setPrompt(NULL);
}
if ($this->getUserPage()) {
$mainRoute->addManyToOne('author', 'Author')->setDisabled(TRUE);
}
if ($this->getTagPage()) {
$mainRoute->addContentTags('tags', 'Tags')->getControlPrototype()->class[] = 'input-block-level';
}
$mainRoute->setCurrentGroup($form->addGroup('Layout'));
if ($form->data->page->parent) {
$mainRoute->addCheckbox('copyLayoutFromParent', 'Layout from parent');
} else {
$mainRoute->addHidden('copyLayoutFromParent', 'Layout from parent');
}
$mainRoute['copyLayoutFromParent']->addCondition($form::EQUAL, FALSE)->toggle('group-layout_' . $form->data->id);
if ($form->data->page->parent) {
$mainRoute->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout_' . $form->data->id));
} else {
$mainRoute->setCurrentGroup($form->getForm()->addGroup('Layout')->setOption('id', 'group-layout_' . $form->data->id));
}
$mainRoute->addManyToOne('layout', 'Layout');
$mainRoute->setCurrentGroup($form->addGroup());
$mainRoute->addCheckbox('copyLayoutToChildren', 'Share layout with children');
$mainRoute['copyLayoutToChildren']->addCondition($form::EQUAL, FALSE)->toggle('group-layout2_' . $form->data->id);
$mainRoute->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout2_' . $form->data->id));
$mainRoute->addManyToOne('childrenLayout', 'Share new layout');
// Navigation
$page->setCurrentGroup($form->addGroup('Navigation'));
$page->addCheckbox('navigationShow', 'Show in navigation')->addCondition($form::EQUAL, TRUE)->toggle('form-navigation-own');
if (!$form->data->page->mainRoute->locale) {
// languages
/** @var $repository \DoctrineModule\Repositories\BaseRepository */
$repository = $form->mapper->entityManager->getRepository('CmsModule\\Content\\Entities\\LanguageEntity');
if ($repository->createQueryBuilder('a')->select('COUNT(a.id)')->getQuery()->getSingleScalarResult() > 1) {
$page->setCurrentGroup($form->addGroup('Languages'));
$page->addManyToOne("language", "Content is in")->setPrompt('shared');
}
}
$form->setCurrentGroup();
$form->addSaveButton('Save');
$js = '
function detectAuto() {
$("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").unbind("keyup keydown blur");
$("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").stringToSlug({getPut: ".localUrlTemplate", space: "-" });
$("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").trigger("keyup");
if($("#form-checkbox").is(":checked")) {
$("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").stringToSlug({getPut: ".localUrl", space: "-" });
}
if($("#form-checkbox-title").is(":checked")) {
$("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").bind("keydown keyup blur", function(){
$(".formTitle").val($(this).val());
//.........这里部分代码省略.........