symfony-forms

how can I define a value for model's field in symfony?

I'm building an app for the company I work for in symfony, non the less the app might be pretty useful outside our company so we decided to write it in a more general form so we can make it multi company. I'm facing a problem on how to define a default value for a field that is going to be in every single model (company_id) so we don't ...

symfony override BaseForm class howto

I've installed the sfDoctrineGuard plugin. Everything is working, I can use the /sf_guard_user/edit/:id page to edit a user. I didn't like the way the permissions were listed as a select list, I wanted to display them as individual checkboxes split up based on the permission name. To do this I created a custom widget that extends sfWidg...

Symfony - updating unique column - validation problem

I'm new to Symfony Framework and I ran into a problem with form validation. I want to update data in DB including unique column, but if unique column is unchanged, an error is returned (An object with the same "domain" already exist."). Domain column must be unique, but user should be able to change it. So, if one user saves his domain ...

Widget "password_again" does not exist.

Got this error: Widget "password_again" does not exist. I can't think why it has suddenly started appearing. I'm using the default generator file supplied with the sfDoctrineGuard plugin plugins/sfDoctrineGuardPlugin/modules/sfGuardUser/config/generator.yml generator: class: sfDoctrineGenerator param: model_class: sfGuardU...

In symfony forms how I can validate a field (i.e. password) querying the db for the right value ?

Newbie question. I've created a very simple LoginForm class in symfony. It checks if the user inserts the username and the password in the field and It work as expected. // UserLoginForm :: configure() $this->setWidgets(array( 'username' => new sfWidgetFormInputText(), 'password' => new sfWidgetFormInputPassword(), )); $this->setV...

How to display a sfWidgetFormSelectRadio item without showing the label

I am using Symfony 1.3.6 on Ubuntu 10.0.4. I am using the sfWidgetFormSelectRadio to allow a user to select a picture from a list, in a form. In the action, the pictures are set up like this: $this->form->setWidget('chosenpic', new sfWidgetFormSelectRadio(array( 'choices' => $this->pictures, ...

how can I find out if a method exist for a doctrine model in symfony?

I have a doctrine model that has a method getSomethingId() and I'm making something of an automated form generator for internal use in the company how can I check if my model has this method? I've tried with php's method_exists but it returns false for every method, what can I do? thanks ...

'Invalid' error for sfWidgetFormChoice when form is submitted.

Hi, i want to display combo box using symfony. In the CountryForm.php i have created widget as : $this->setWidgets(array('country' => new sfWidgetFormChoice(array('choices' => array())))); for this validator as: $this->setValidators(array('country' => new sfValidatorChoice(array('choices' => array(array_keys($countries)))))); I am ge...

HowTo: display custom error message when unique index fails on object save

I have added an index on a table just to ensure that a set of fields together form a composite unique key (Is this approach correct? or is there a better option with Doctrine?) After having done that, when I try to save an object and the unique constraint fails, a SQL exception is generated. What is the best way to handle this? and to d...

Symfony - set form value on save

Hi all, A quick question. I have a symfony form. When I save the form, I want my created_by field to be set automatically on save. So, i'm passing the current user id as an option in the form: $this->form = new ContractForm(null,array("created_by"=>$this->getUser()->getId())); And in the configure method of the form class I have: $...

How to throw an error in an embedded form's post validator (sfForm)

With Symfony 1.4's Forms, how can I throw a sfValidatorError in the post validator of an embedded form? My parent form calls the following: public function configure(){ $this->embedForm('page', $pageLinkForm); } And my embedded form: public function configure(){ $this->validatorSchema->setPostValidator(new sfValidatorCallbac...

How to 'validate' a Symfony form in steps - instead of calling $form->isValid()

I am using Symfony 1.3.6 on Ubuntu. I have a form with a lot of fields on it - rather than showing all the fields in one go (which may intimidate the user), I want to break up the form into stages, so that a user can fill in only the fields displayed, at each step/stage (kinda like a wizard). In order to do that, I need to write custom...

Stop symfony from escaping html from query result

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...

Symonfy 1.4 dynamic validation possible?

Hi all, I'm trying to create a form that change the validation of a field based on the select option from the html form field. Ex: if user select a option 1 from drop down field "options", I want the field "metric" to validate as sfValidatorInteger. If user select option 2 from field "options", I want the field "metric" to validate as...

How do I embed sfDoctrineGuardPlugin register/signup form into my homepage module template?

So far I have copied sfGuardRegister into my frontend app modules directory so it has taken over the default sfGuardRegister located in the sfDoctrineGuardPlugin directory in the symfony plugins directory. I want to have the plugins sfGuardRegister signup/register form show up on my homepage template.. Thanks in advance ...

Best way to recursively merge array without overwriting duplicates keys

I have a multidimensional array of form data thats an been unserialized from YAML. As such it looks something like this: Array( 'name' => 'Somone', 'email' => '[email protected]', 'billing' => Array( 'address_1' => '1234 Somewhere' 'address_2' => NULL, 'city' => 'Somewhere', 'state' => 'ST' 'country' => '...

symfony form validation clean with regex before validate with regex

Hi, I'm using Symfony 1.4 and am a little stuck regarding form validation. I have a validator like the one below: $this->setValidator('mobile_number', new sfValidatorAnd(array( new sfValidatorString(array('max_length' => 13)), new sfValidatorRegex(array('pattern' => '/^07\d{9}$/'), array('invalid' => 'Invalid mobile number.'...

Symfony merge two forms that have a field with the same name

Hi I have two forms, a Specification form and a Source form. I'm merging the two forms into one so that users can submit a specification and the source of the specification at the same time. The problem is that the specification table has a field called name and the source table has a field called name. So, when creating the forms and...

Symfony forms or normal HTML forms

I am using Symfony 1.4 to create project, and i need to create dynamic forms depending upon the question set type coming from database. i have used Symfony forms in rest of my project, but in this case using symfony forms seems to be tough, as i need dynamic form. can it be safe to use normal HTML forms..in symfony project, or it is advi...

To set symfony validators for custom HTML elements

I have created custom HTML form elements to take inputs from user, and i am not using the Symfony Form. i know that it keep me out of Symfony form validation system, Is there any way to use custom HTML element and get Symfony Form validation on that elements. I have used Symfony forms and i know how to use validators, but this time i am ...