[英]Get form value from Sonata Admin
I would like get value from form of Sonata Admin, but in source html i have for example: 我想从Sonata Admin的形式获取价值,但是在源HTML中,例如:
<input type="text" class="span5" maxlength="255" required="required" name="s215268450cfc7[username]" id="s215268450cfc7_username">
s215268450cfc7 this is uniqid, but for what this is add to all fields in form? s215268450cfc7这是唯一的 ,但是为什么要添加到表单中的所有字段? This is regenerate after refresh page.
刷新页面后将重新生成。
I would like get value from this form, but i can't use: 我想从这种形式获得价值,但是我不能使用:
$('#s215268450cfc7_username').val()
because this is still renames. 因为这仍然是重命名。
You can parse uniqId
from the <form>
element, or you can use: 您可以从
<form>
元素解析uniqId
,或者可以使用:
$('form [id$="_username"]').val()
Also, from Twig template, you can access name something like this (depending on whether you have access to the whole form, or only to the username field): 另外,从Twig模板中,您可以访问类似这样的名称(取决于您是访问整个表单还是仅访问用户名字段):
{{ form.children.username.vars.name }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.