我正在使用SonataAdminBundle(使用Doctrine2 ORM),并且我已成功为我的Picture模型添加了文件上传功能.
我想在" 显示"和" 编辑"页面上,<img src="{{ picture.url }} alt="{{ picture.title }} />在相关表单字段上方显示一个简单标记(假设正在编辑的图片当然不是新的),以便用户可以看到当前照片,并决定是否改变与否.
经过几个小时的研究,我一直无法弄清楚如何去做.我想我需要覆盖一些模板,但我有点迷失...有人可以给我一个提示吗?
谢谢!
这是我的PictureAdmin类的相关部分.
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('category', NULL, ['label' => 'Catégorie'])
->add('title', NULL, ['label' => 'Titre'])
->add('file', 'file', ['required' => false, 'label' => 'Fichier']) // Add picture near this field
->add('creation_date', NULL, ['label' => 'Date d\'ajout'])
->add('visible', NULL, ['required' => false, 'label' => 'Visible'])
->add('position', NULL, ['label' => 'Position']);
}
protected function configureShowFields(ShowMapper $showMapper)
{
$showMapper
->add('id', NULL, ['label' …Run Code Online (Sandbox Code Playgroud) 我做了一个过滤器只是为了在一个值之后添加一个反斜杠,如果另一个给定的值不为空,我想将这个反斜杠与字符串的其余部分分开 .实际上,过滤器本身可以正常工作,但正如页面中的字符串""一样.
angular.module('ngMod', []).
filter('antislash', function() {
return function(input) {
if( input==null || input.length === 0 ){
return null;
}else{
return ' / ';
}
}
});
Run Code Online (Sandbox Code Playgroud)
它显示在页面中: /
是否存在html过滤器或等效的东西?
symfony2是否可以使用正则表达式为单个Controller Action定义多个url模式,因此我们不必定义多个规则?提前致谢
该命令grunt imagemin将以下内容输出到随机文件.
Fatal error: ENOENT, no such file or directory 'app/public/assets/img/epg/recordseries.png'
Run Code Online (Sandbox Code Playgroud)
有趣的是,每次我再次运行命令grunt imagemin时,它会设法处理更多文件,并通过输出有关另一个文件的相同错误而结束.
我正在使用
node v0.10.24
npm 1.3.21
grunt@0.4.2
grunt-contrib-imagemin@0.5.0 node_modules/grunt-contrib-imagemin
+-- filesize@2.0.0
+-- async@0.2.9
+-- chalk@0.4.0 (has-color@0.1.2, ansi-styles@1.0.0, strip-ansi@0.1.1)
+-- image-min@0.1.2 (mkdirp@0.3.5, cache-file@0.1.2, mout@0.7.1, optipng-bin@0.3.1, jpegtran-bin@0.2.3, gifsicle@0.1.4)
Run Code Online (Sandbox Code Playgroud)
这是我的grunt配置imagemin任务:
grunt.config('imagemin', {
options: {
optimizationLevel: 3, // 0 to 7, default =7)
// pngquant: true
},
dynamic: { // Multiple target
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= context.source %>/assets/img/', // equal to app/wesource/assets/img/ …Run Code Online (Sandbox Code Playgroud) 在一个表单中,我有一个文件输入皮肤用jquery和css和一个提交按钮.
<form action="#" method="POST">
<input style="width:150px" type="hidden" name="MAX_FILE_SIZE" value="40000"/>
<div class="l-input-file">
<input style="margin-bottom: 0px" type="file" id="myInput" name="myInput" size="16" />
</div>
<div><button type="submit" class="btn-black">Continuer</button></div>
</form>
Run Code Online (Sandbox Code Playgroud)
此处的问题仅出现在IE10上:选择文件后,必须单击提交按钮2次才能提交表单.
当文件输入改变但我没有帮助时,我尝试强制关注按钮.
我尝试使用jQuery触发click,
jQuery('#myInput').parents('form').find("button[type='submit']").click();
Run Code Online (Sandbox Code Playgroud)
但在第三次提交之前,我收到了2次"拒绝访问"的消息.
任何意见或建议将受到强烈赞赏.谢谢
在树枝模板中是否可以形成带有变量的翻译键?
喜欢
{% trans %}detail.label.price.{{membership}}.credit{% endtrans %}
要么
{% set str = "detail.label.price"+membership+".credit"|trans %}
将文件的本地文件夹拖到devtools中会将它们添加到工作区,以便您可以持久地编辑它们.我刚刚发现了这个功能.然而,我的文件都是Babel被编译,然后我编辑了一个文件并点击cmd -s保存更改Chrome检查源并跳过es6 import语句,错误如下:Unexpected token import
有没有办法让chrome不检查语法?如果它只是编辑文件而不试图编译它,Babel就可以拿起它并通过热模块更换注入更改.
在使用generator-react-server加载 SVG 文件生成的 react-server 项目中,如 follow 会触发反应错误。
const fmc = require('../images/logo.svg');
Run Code Online (Sandbox Code Playgroud)
给出错误
Failed to load page at "../pages/home.js" ReferenceError: React is not defined
at Object.<anonymous> (/Users/me/Projects/myProject/dev/images/logo.svg:1:1)
at Module._compile (module.js:541:32)
at loader (/Users/svasseur/Projects/delateurs/dev/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/svasseur/Projects/delateurs/dev/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/me/Projects/myProject/dev/components/footer.js:5:13)
Run Code Online (Sandbox Code Playgroud)
我试图像我在以前的项目中那样为 SVG 加载器指定 webpack 文件加载器,但它不起作用。这是我在.reactserverrc中定位的webpack.conf.js文件作为"webpack-config": "./webpack.config.js"
export default (webpackConfig) => {
webpackConfig.module.loaders.splice(0, 0,
{ test: /\.woff(2)?(\?v=\d+\.\d+\.\d+)?$/, loader: …Run Code Online (Sandbox Code Playgroud) 我正试图在这样的自定义枝条过滤器中使用翻译
public function formatTime($timestamp)
{
$str = date('j %\m%',$timestamp);
$str = str_replace($str, '%m%', $this->get('translator')->trans('month'.date('m', $timestamp) ) );
return $str;
}
Run Code Online (Sandbox Code Playgroud)
当然得到的是未知的功能.我是否应该让我的扩展程序了解环境或只是请求翻译课程使其可用?
我按照以下Symfony2食谱教程,但我一直收到错误
constraint myContraintClass cannot be put on properties or getters
在validation.yml我有
Core\Entity\Activity:
properties:
maxTotalParticipant:
- Application\ActivityBundle\Validator\ActivityMaxTotalParticipant: ~
Run Code Online (Sandbox Code Playgroud)
这是我的约束
<?php
namespace Application\ActivityBundle\Validator;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class ActivityMaxTotalParticipant extends Constraint
{
public $message = 'trigger error';
public function validatedBy() {
return 'activity_max_total_participant_validator';
}
public function getTargets() {
return self::CLASS_CONSTRAINT;
}
public function getMessage() {
return $this->message;
}
}
Run Code Online (Sandbox Code Playgroud)
和我的约束验证器
<?php
namespace Application\ActivityBundle\Validator;
use Symfony\Component\Validator\ExecutionContext;
use Symfony\Bundle\DoctrineBundle\Registry;
use myApp\Core\Entity\Activity;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation;
class …Run Code Online (Sandbox Code Playgroud) 我不知道如何配置检查是否$remote_user等于location.
location / {
auth_basic "ElasticSearch";
auth_basic_user_file /etc/nginx/search_passwords;
location ~/([^/]*)/ { # named capture did not work either
if ($remote_user = $1) { # ERROR: Unknown variable: $1 / $NAMEDWHATEVER
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的用例:
我正在尝试通过使用 nginx 反向代理进行身份验证来“保护” ElasticSearch-Cluster。我想允许多个用户,但新用户的修改应该尽可能简单;最好的情况 - 只需更改 htpasswd 文件。
我正在尝试采用nginx-elasticsearch-proxy,但无法检查remote_name和index-name是否相等。
我正在使用本手册https://golb.hplar.ch/2018/01/Sending-Web-push-messages-from-Spring-Boot-to-Browsers.html的示例来研究推送通知。我面临的问题是,当我运行应用程序时,出现错误
Parameter 1 of constructor in ru.stepanb.MetricPushingApplication.push.PushChuckJokeService required could not be found.
Consider defining a bean of type 'org.springframework.web.reactive.function.client.WebClient' in your configuration.
Run Code Online (Sandbox Code Playgroud)
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
@Service
public class PushChuckJokeService {
private final FcmClient fcmClient;
private final WebClient webClient;
private int seq = 0;
public PushChuckJokeService(FcmClient fcmClient, WebClient webClient) {
this.fcmClient = fcmClient;
this.webClient = webClient;
}
@Scheduled(fixedDelay = 30_000)
public void sendChuckQuotes() {
IcndbJoke joke =
this.webClient.get().uri("http://api.icndb.com/jokes/random")
.retrieve().bodyToMono(IcndbJoke.class).block();
try {
sendPushMessage(joke);
}
catch (InterruptedException | ExecutionException …Run Code Online (Sandbox Code Playgroud) 我正在翻译以下密钥 activity.fr.yml
user.list.link: '{1}et %count% autre|]1,Inf[voir les %count% autres'
Run Code Online (Sandbox Code Playgroud)
使用tranchoice
<a href="{{ moreLink }}" >{% transchoice count from "activity" %}user.list.link{% endtranschoice %}</a>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
An exception has been thrown during the rendering of a template ("Unable to choose a translation.")
我认为翻译已被发现,否则我不会得到关于无法选择翻译但关键本身的错误.
同样yaml甚至其他tranchoice的所有其他键都很好地翻译.
我跟着文档,尝试添加with {'%count%': count}没有成功.
有人知道这里有什么问题吗?提前致谢
symfony ×6
translation ×3
file-upload ×2
twig ×2
angularjs ×1
babeljs ×1
constraints ×1
ecmascript-6 ×1
filter ×1
gruntjs ×1
html ×1
image ×1
input ×1
javascript ×1
jquery ×1
key ×1
nginx ×1
php ×1
pluralize ×1
react-server ×1
reactjs ×1
regex ×1
routing ×1
spring-boot ×1
string ×1
svg ×1
url ×1
validation ×1
webpack ×1
yaml ×1