symfony2-forms

Initialize custom type form data

依然范特西╮ 提交于 2019-12-12 02:56:28
问题 I have defined a custom form like this: class EditOwnerProfileType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add("user", new UserType()) ->add("dog", new DogType()) ->add('save', 'submit'); } public function getName() { return 'edit_owner'; } } I want to create this form and initialize it with some data like this: $user = new User(); $user->setLatitude(1.1) ->setLongitude(2.2) ->setAddress("custom address"); $dog = new Dog();

Symfony - CSRF token is invalid - FosRestBundle

最后都变了- 提交于 2019-12-11 05:15:00
问题 I'm using Symfony and FosRestBundle. When I want to simply test my rest api, I got this : The CSRF token is invalid. Please try to resubmit the form. /** * @example ["titre", "short description", "description", "2016-10-10", 200, "with complete data"] * @example ["titre", "short description", "description", "2016-10-31", 200, "with complete data"] */ public function editNewsTest(ApiTester $I, Example $example) { $I->wantTo('edit a news (' . $example[5] . ')'); $I->haveHttpHeader('Content-Type

Allow to add a new value in a choice Field Type

早过忘川 提交于 2019-12-03 12:11:11
问题 I use Form Component and have a choice Field Type on a form which is rendered to a select field. On a client-side I use select2 plugin which initializes the select with the setting tags: true wich allows to add a new value in it. But if I add a new value then a validation on a server will fail with error This value is not valid. because the new value isn't in a choice list. Is there a way to allow adding of a new value to choice a Field Type? 回答1: The problem is in a choice transformer, which

Allow to add a new value in a choice Field Type

痞子三分冷 提交于 2019-12-03 02:42:18
I use Form Component and have a choice Field Type on a form which is rendered to a select field. On a client-side I use select2 plugin which initializes the select with the setting tags: true wich allows to add a new value in it. But if I add a new value then a validation on a server will fail with error This value is not valid. because the new value isn't in a choice list. Is there a way to allow adding of a new value to choice a Field Type? Vasily The problem is in a choice transformer, which erases values that don't exist in a choice list. The workaround with disabling the transformer