当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::getTranslator方法代码示例

本文整理汇总了PHP中Venne\Forms\Form::getTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getTranslator方法的具体用法?PHP Form::getTranslator怎么用?PHP Form::getTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Venne\Forms\Form的用法示例。


在下文中一共展示了Form::getTranslator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
//.........这里部分代码省略.........
开发者ID:svobodni,项目名称:web,代码行数:101,代码来源:BasicFormFactory.php


注:本文中的Venne\Forms\Form::getTranslator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。