formbuilder

Using Symfony2 UserPassword validator in form type

拜拜、爱过 提交于 2019-12-10 15:04:38
问题 Im trying to use a specific validator in a form. That form is for an user to redefine his password, he must also enter his current password. For that I use a built in validator from symfony in my form: use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; and the form type looks like that: /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('currentpassword', 'password

how to check the user role inside form builder in Symfony2?

北城以北 提交于 2019-12-10 02:21:08
问题 Okay, i'm trying to check if an user has a specific role, i did this however, when i do this: public function buildForm(FormBuilder $builder, array $options) { $builder ->add('nombre',null,array('label' => 'Usuario')) ->add('email') ->add('password', 'repeated', array( 'type' => 'password', 'invalid_message' => 'Los campos deben coincidir', 'first_name' => 'password', 'second_name' => 'confirmar password', 'options' => array('required' => false) )) ->add('cliente', 'entity', array( 'class' =>

Symfony form not saving entity with ManyToMany relation

只愿长相守 提交于 2019-12-09 18:45:50
问题 I have problem saving entity trough form with ManyToMany relations. I can not save fields that are on "mappedBy" side of relation. Code below is not saving anything to database and not trowing any errors: // Entity/Pet /** * @var \Doctrine\Common\Collections\Collection * * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Customer", mappedBy="pet", cascade={"persist"}) */ private $customer; /** * Set customer * * @param \AppBundle\Entity\Customer $customer * @return Pet */ public function

Implicit argument passing of super from method defined by define_method() is not supported

醉酒当歌 提交于 2019-12-09 14:47:51
问题 In " Agile Web Development with Rails " (third edition) page 537 - 541 it has "Custom Form Builders" code as follows: class TaggedBuilder < ActionView::Helpers::FormBuilder # <p> # <label for="product_description">Description</label><br/> # <%= form.text_area 'description' %> #</p> def self.create_tagged_field(method_name) define_method(method_name) do |label, *args| @template.content_tag("p" , @template.content_tag("label" , label.to_s.humanize, :for => "#{@object_name}_#{label}") + "<br/>"

Angular7报错:Can&apos;t bind to &apos;formGroup&apos; since it isn&apos;t a known property of &apos;form&apos;

China☆狼群 提交于 2019-12-09 13:02:38
报错问题:Can't bind to 'formGroup' since it isn't a known property of 'form' 报错提示: Uncaught Error: Template parse errors: Can't bind to 'formGroup' since it isn't a known property of 'form'. ("</p> <form [ERROR ->][formGroup]="loginForm"> <label> "): ng:///AppModule/LoginComponent.html@7:6 问题原因: 没有导入表单模块。 解决办法: 从 @angular/forms 中导入 ReactiveFormsModule 模块。 import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 修改后代码实例 login.component.ts 代码: import { Component } from '@angular/core'; import { Router } from '@angular/router'; import { FormBuilder, FormControl, FormGroup, Validators } from

Can the Symfony2 form builder be used for the login form?

穿精又带淫゛_ 提交于 2019-12-08 05:06:03
问题 I have spent the last several hours trying to get a login form built with the Symfony form builder to work. As far as I can tell, the problem is that the form builder creates field names of the form formName[fieldName] (e.g., login[_username]) and the security component looks for "flat" field names (e.g., _username). This results in a CSRF failure on submit. I have been unable to find any way to coerce the form builder into producing flat field names. Does anyone know of a way to use the form

In Symfony2, how do I get labels from the FormBuilder

故事扮演 提交于 2019-12-07 20:01:41
问题 In Symfony2, I'm using formbuilder. I'm setting the labels in the form, as per the documentation. However, when I'm on the 'show' and 'index' pages, I have to copy the labels into Twig. Is there a way to have the same labels used everywhere? The options I have thought of: Access the formbuilder configuration, but without actually building the form Have a central config file, and lookup from the formbuilder and the twig files into that file However, either way requires me to 'do' something,

How to create Orbeon custom control XBL with predefined visibility, control name, default value?

不问归期 提交于 2019-12-07 01:43:31
I have created a custom control (hidden text box with some predefined value), where I want to set visibility=false() , controlName="Mycustom" , default value="This is my custom control" in XBL file. So that whenever we use that custom control from Orbeon Form Builder, it will come with all default values with no need to set anything. XBL: <xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xxi="http://orbeon.org/oxf/xml

Angular 2 Formbuilder with Observables as default values

萝らか妹 提交于 2019-12-07 01:29:24
问题 I have a problem with the default value of an Angular 2 Form (formbuilder): My default values are observables (which I'm retrieving from a server), so I can't implement them like this: export class UserComponent implements OnInit{ userForm: ControlGroup; userData: any; // Initialise the observable var ngOnInit():any { this.userData = this._dataService.getAllData() // My Observable .subscribe( data => { this.userData = data; } ); this.userForm = this._formBuilder.group({ // below the default

How to add a repeated form in a loop symfony2 for the same entity

社会主义新天地 提交于 2019-12-06 15:13:42
问题 I want to build a questionnaire form. When I use the following code, I can only see the last question of my table that contains 18 questions (and the answer field). I can't use a collection because my questionnaire is going to be more complicated, some questions with multiple answers, some others in true/false, etc. I simplified the code to fix this problem first. //Get question array collection $questions = $questionnaire->getQuestions(); $formBuilderQuestionnaire = $this->createFormBuilder(