因为我有一个自定义构建的jQuery插件来将文件上传传递给我的symfony2 webapp,我正在寻找在控制器中处理这个上传的方法.
我目前拥有的标准(非ajax)文件上传(并且适用于同步调用)看起来像这样
控制器摘录
...
$entity = new Image();
$request = $this->getRequest();
$form = $this->createForm(new ImageType($createAction), $entity);
$form->bind($request); // <-- Find a way to make this connection manually?!
//check that a file was chosen
$fileExists = isset($entity->file);
if ( ($form->isValid()) && ($fileExists) ) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
}
...
Run Code Online (Sandbox Code Playgroud)
表单类型:表单只接受文件和名称:
class ImageType extends AbstractType
{
...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$createAction = $this->createAction;
if ($createAction) {
$builder
->add('file')
;
}
$builder
->add('name', 'text', array('label' …Run Code Online (Sandbox Code Playgroud) 我有一个数据,其结构如下:
var data = {
0: {
user: 1,
job: "call center"
},
1: {
user: 2,
job: "programmer"
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想将它们转换为如下所示的对象数组:
[Object {user : 1, job : call center}, {user : 2, job : programmer} ]
Run Code Online (Sandbox Code Playgroud)
是否可以?我怎样才能转换它们。任何帮助,谢谢。
我想有选择地避免用CKEDITOR.replaceAll替换textareas.我不能简单地使用替换.我必须使用文档中提到的自定义断言函数.
http://docs.ckeditor.com/#!/api/CKEDITOR-method-replaceAll
// Selectively replace <textarea> elements, based on custom assertions.
CKEDITOR.replaceAll( function( textarea, config ) {
// An assertion function that needs to be evaluated for the <textarea>
// to be replaced. It must explicitely return "false" to ignore a
// specific <textarea>.
// You can also customize the editor instance by having the function
// modify the "config" parameter.
} );
Run Code Online (Sandbox Code Playgroud)
但是assert在javascript中没有.断言的语法是什么?
当仅使用一个文件运行Jest(23.5.0)时,它将输出“描述名称”和“测试名称”。我希望Jest在与多个测试文件一起运行时输出“描述名称”和“测试名称”,但这似乎是自动禁止的。
例:
PASS src/components/UsersTable.test.jsx
UsersTable
? is a table (4ms)
? has columns 'first', 'last', 'email' (1ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 1.768s, estimated 2s
Ran all test suites.
Run Code Online (Sandbox Code Playgroud)
当运行两个时,它会抑制。例:
PASS src/components/UsersTableRow.test.jsx
PASS src/components/UsersTable.test.jsx
Test Suites: 2 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 2.254s
Ran all test suites.
Run Code Online (Sandbox Code Playgroud)
部分代码示例:
describe('UsersTable', () => {
const component = renderer.create(
<UsersTable />
); …Run Code Online (Sandbox Code Playgroud) javascript ×3
assert ×1
assertion ×1
assertions ×1
ckeditor ×1
css ×1
file-upload ×1
font-awesome ×1
forms ×1
jestjs ×1
jquery ×1
php ×1
symfony ×1
testing ×1
unit-testing ×1