forms

symfony2: setting the value of a form field outside the form, inside a controller action

蹲街弑〆低调 提交于 2020-01-10 08:59:13
问题 I need to set the value of a symfony2 form element. I use a doctrine2 entity, a Symfony\Component\Form\AbstractType and the createForm() method inside my Controllers Action. $saleDataForm = $this->createForm(new SaleType(), $sale); Now, how do i get an element from that form, and how can i set it's value? I want to do something like this, but it doesn't work: $saleDataForm->get('image')->setValue('someimapge.jpg'); FYI: I need to do this to render the field correctly (using this approach, my

PHP form + Google reCAPTCHA

北城余情 提交于 2020-01-10 08:38:29
问题 It's kind of weird that Google's documentation for recaptcha is not as helpful as I thought it was going to be. I was asked to take a current existing form (which is getting spammed a few times a day) and update it with Google's new recaptcha. There are a lot of tutorials out there for the old captcha, but not so many for the new one. I basically just want a simple form to capture name, email, message, and then replace my current "anti-bot field" with the recaptcha (I used a field that

Rails - Displaying Foreign Key References in a form

不问归期 提交于 2020-01-10 07:59:07
问题 I'm doing a simple exercise with two models. Sport and Teams, defined as rails g scaffold sport name:integer rails g scaffold team name:integer fans:integer sport:references (Note: The reason I'm using scaffold is rapidly prototyping so I can learn/experiment with the parts I'm not familiar with yet) Problem is that my "sport" (i.e. the foreign key reference) is showing like the following So it's got that weird #<blahl blah> notation to it... <%= form_for(@team) do |f| %> <% if @team.errors

JSON Hypermedia Api with forms and links

无人久伴 提交于 2020-01-10 07:58:08
问题 I am in the early stages of planning a REST api, and I would like for it to adhere to the HATEOAS constraint of REST. But I would also like to provide a JSON format. So my question is if there are conventions out there to represent links and forms in JSON. I have found examples of links, and it looks like this is a pretty common way of representing links: "links": [ {"rel": "self", "href":"http://example.org/entity/1"}, {"rel": "friends", "href":"http://example.org/entity/1/friends"}]

Symfony2 - Set a selected value for the entity field

爷,独闯天下 提交于 2020-01-10 04:51:47
问题 I'm trying to set a selected value inside an entity field. In accordance with many discussions I've seen about this topic, I tried to set the data option but this doesn't select any of the values by default: class EventType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('place', 'entity', array( 'class' => 'RoyalMovePhotoBundle:Place', 'property' => 'name', 'empty_value' => "Choisissez un club", 'mapped' => false, 'property

Angular forms and password managers

泪湿孤枕 提交于 2020-01-10 04:38:26
问题 I use Angular forms to do signup & login on my frontend. It is a classic setup where the POST requests going out of the form are sent to a backend API. The POST requests are sent from the submit function that I register with (ngSubmit)=onSubmit() on the form element. I'd like password managers to play ball with this: save login/password on user creation, autofill on login, update on password change. Everthing works ok with Dashlane. But I recently tried Lastpass and it didn't catch the

JQuery Clear Form on close

随声附和 提交于 2020-01-10 03:04:49
问题 I have the below JQuery Dialog script, I'm trying to find out how to fire off a function that clears the form when I close the dialog. function clearForm() { $(':input','#calcQuery') .not(':button, :submit, :reset, :hidden') .val(''); }; // form popup $(document).ready(function() { //var dataString = $("#calcQuery").serialize(); $("#formBox").dialog({ bgiframe: true, autoOpen: false, height: 600, width: 400, modal: false, closeOnEscape: true, title: "Calculator", buttons: { "Calculate":

How to use antd.Form.create in typescript?

老子叫甜甜 提交于 2020-01-09 19:17:18
问题 I have a login form created by Form.create(), but I can't pass any props to this form from parent component, compiler always notify a error like error TS2339: Property 'loading' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Compone nt<{}, ComponentState>> & Readonly<{ childr...'. LoginForm.tsx import * as React from 'react'; import { Form } from 'antd'; import { WrappedFormUtils } from 'antd/lib/form/Form'; interface Props { form: WrappedFormUtils; loading: boolean;

HTML5 input type number not working in firefox

和自甴很熟 提交于 2020-01-09 11:35:54
问题 I am using HTML5 input type=number . Its working perfectly in Chrome browser, but its not working in Firefox and IE9. I want to increment the quantity by one i.e. step=1 and also I have set min=1 . I am using the following code: <form action="" class="cart" method="post" enctype='multipart/form-data'> <div class="quantity"> <input type="number" step="1" min="1" name="quantity" value="1" title="Qty" class="input-text qty text" /> </div> <button type="submit" class="single_add_to_cart_button

Update a formControl that is a file input in a formArray in Angular2

∥☆過路亽.° 提交于 2020-01-09 11:19:59
问题 I have the code below: import { Component, OnInit, ElementRef } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms' @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { showSort: boolean = false; form: FormGroup; name: FormControl; sortSelf: FormControl; sortItem: FormArray; locationItems: FormArray; constructor(private _fb: