symfony-forms

Stop symfony from escaping html from query result

北城余情 提交于 2019-12-12 05:58:33
问题 Currently I am using ckEditor with ckFinder in Symfony. When I save a form the HTML is saved (seemingly so) properly in the database. When I query through symfony and retrieve the results, the html tags are removed and replaced. Can I prevent this? Below is an example of what is in the database. I tried putting in what the HTML Shows but the current eidtor translates it Database shows: <p> Test</p> <p> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download

Validation doesn't work on relation fields

醉酒当歌 提交于 2019-12-12 05:30:54
问题 I have OnetoOne relation between Users and Files, The problém is that every time i post a new file via embed form the validiation does not work . I tried this solution mentioned in symfony doc To prevent validation on objects that are embedded as properties on an object being validated we need to add @Assert\Valid in the first filed. Also i tried to validate even a string not a file and this didnt work. By the way any validation mentioned in Users class, works fine. Files.php <?php namespace

Symfony Forms Assert

故事扮演 提交于 2019-12-12 04:36:58
问题 I have Event class that has a field like this : class Event { ...... /** * @var datetime $date * * @ORM\Column(name="date_debut_inscri", type="datetime") * @Assert\GreaterThanOrEqual("today UTC") */ protected $dateDebutInscri; ...... } This field is hidden when a checkbox is checked and it's set to null in the controller, the problem is when this field is hidden the Assert error message still appears and that makes me unable to submit my form I want it to be null by default and if the user

Symfony submit to same url

倖福魔咒の 提交于 2019-12-12 04:17:11
问题 I have a form with some text fields and I have a preview button that needs to submit the form to the same controller. And then in the controller, I need to extract the values and populate a form with these values for the template to see. What is the best way to achieve this? I'm a newbe so please be clear. 回答1: Sample controller: public function myControllerName(sfWebRequest $request) { $this->form = new myFormClass(); } Use <?php echo $form->renderFormTag( url_for('@yourRoutingName'), array(

Symfony2 forms with multiple dependent fields

霸气de小男生 提交于 2019-12-12 02:52:22
问题 I am creating a registration from which have the following format. If country changes then i need to change the child fields accordingly. 1- Country States Cities Suburbs In my COMPANY BRANCH entity i am saving suburb key as one-many. Company branch located in which suburb. if i change the company group then it should change the child's. 2- Company Group Company In my COMPANY BRANCH entity i am saving company key as foreign key. One- many relationship. Company has many branches and one branch

How to get the passed options to a Symfony form

烈酒焚心 提交于 2019-12-12 02:30:30
问题 I'm trying to extend a Symfony 2.8 Form Type, following this http://symfony.com/doc/2.8/form/create_form_type_extension.html In my ObjectType form I have something like this, where I create my form. My form includes a field of Type MyExtendedType public function buildForm(FormBuilderInterface $builder, array $options) { $passed_options = array('aKey'=>'aValue', ...); $builder ->add('someotherfield', 'SomeOtherStandardType', ..) ->add('fieldname', 'AppBundle\Form\Type\MyExtendedType', $passed

Unable to extract translation id for form label with JMS Translation Bundle

不羁岁月 提交于 2019-12-12 02:13:27
问题 I'm using the JMS Translation Bundle to extract my translations. Everything works, but when I try to extract my translation messages form a form builder I recieve following message: [JMS\TranslationBundle\Exception\RuntimeException] Unable to extract translation id for form label from non-string values, but got "PHPParser_Node_Expr_MethodCall" in /srv/local.project.com/app/../src/Project/MyBundleBundle/Form/Type/EmailType .php on line 30. Please refactor your code to pass a string, or add "/*

Symfony2 FormType optional whole or nothing

耗尽温柔 提交于 2019-12-12 01:37:35
问题 I have form in Symfony2 containing 2 sub form types representing 2 relations in my entity. invoiceAddress is required always and it works OK, but i want deliveryAddress keep optional only when all inputs of deliveryAdress are empty. When i set it like not required symfony sets deliveryAddress as null when nothing is filled in form, but when some fields are filled it do not run validation of asserts on that entity. So what i am trying to achieve is tell the symfony when form is whole empty

Distinguish between bubbled errors and field errors in Symfony 2 form theme?

别来无恙 提交于 2019-12-12 01:37:15
问题 How can i distinguish between field errors and bubbled (form) errors? AFAIK the only block that controls this is: {% block field_errors %} {% spaceless %} {% if errors|length > 0 %} <ul> {% for error in errors %} ... {% endfor %} </ul> {% endif %} {% endspaceless %} {% endblock field_errors %} I think i can't rely on errors|length : usually it's 1 for field errors, but can be 1 also for form errors :( 回答1: To me it looks like by default you are unable to separate these errors. But you can

Placing stuff between a Symfony Form label and the widget using Bootstrap

时光总嘲笑我的痴心妄想 提交于 2019-12-11 20:15:03
问题 I want to be able to place one or two small icons between the label of a form and the form widget. What I'd like to get is what can be seen in the "Approach" field above, which is rendere using: {{ form_row(formProjectDetail.approach) }} But then I modified the image to show you where I want the "?" (in reality there is nothing there ;) ). I tried to separate the label from the widget doing {{ form_label(formProjectDetail.name) }} <a data-toggle="modal" href="#modalHelpProjectDetailName">