Yii, form using 2 models -> skip the validation on one - forms

I have one form using to different models. I want to be able to create a new Person and eventually a new User, to give this person an account. A person doens't need to have a User related (could be just a person used for statistics or something like that). I have a checkbox in my form "Click if you want create a user" and I show the user part of the form if it's checked.
Then in the controller I can, with the checkbox value, know if I need call performAjax() for both Person and User or only Person.
But my problem is about the client validation. If I try to submit the form without the User required field, for example, the submition will abort and i'll get some errors like "This field is requiered".
So, my question is how could I skip the validation of my user model if its fields are empty (checkebox unchecked, we don't want to create a user).
Any help are welcom :)
Sorry for my bad English.
Have a good day :)
Michaƫl S.

When saving the model, set the first parameter on false to skip validation:
$model->save(false)

Related

Repeatable Form elements

I need to allow the users repeat some of the form fields(or form groups) in the survey forms. There should be a + or - button next to the field that if the user clicks on +, then a new field is created.
Example: https://www.rhyzz.com/repeatable-fields.html
I would be surprised to know if Qualtrics doesn't have this feature.
I google for this but no success.
You can't create new fields (choices, answers, variables, etc.) on the fly in Qualtrics. A field has to be defined in the survey for it be be saved in the response data.
You could write a JavaScript to show and hide fields to give the appearance of adding and removing fields, but you would have to define the maximum number of fields in the survey beforehand.

Getting current item ID in SharePoint Infopath form

Can we get the current item ID value while submitting the data in InfoPath form.
I need to use this and concatenate the ID with other field value. Tired "Max(#ID) + 1" function but it wouldn't solve the problem.
I know it can be done using calculated column or workflow.
It needs to be done using InfoPath form ? Is it possible ?
You already figured it out yourself. Im assuming you are trying to use the ID in naming it.
Create a blank field.
Then add that field to your submission naming concat.
Create a receive data connection (assuming you havent) to that library.
On the Submit rule add the query action to that library and a set field action to set that new blank field with max(ID) + 1. Make sure Submit action is last.
That should do it unless Im missing something as I have used this many times!

MS-Access: How to create form where user can add results (tblResults) to a tests (tblTests)?

I am creating a database that contains Product information (tblProductInfo), a list of test methods (tblTests), and the results that the product gets (tblResults).
I'm adding forms so that a user can enter the results of a previous or new product. This information will be added once all the testing for that product is done. So, I would like to be able to show a list of the tests from tblTests, and have the user enter the results in a text box of some sort displayed directly next to the tests. I can't figure out a way to do so, where it will then save all the results that the user entered.
I have created a form with a subform, where the subform shows the 2 columns (tests and results) and when I change it to allow DataEntry, it gets rid of all the test names. I need it to keep the test names displayed, but allow entry in the results column.
Any ideas?
Below is a screenshot of an example of what I would like, although I need the Results column to be empty.
Create a continuous subform with only the tblresults as the recordsource, and for the header or each field of results use the related test as the label is how I would do it. Set allow additions to yes, allow edits to no allow deletions to no.

Symfony 1.4 Form Creater

Need: Ability to dynamically build Forms
Structure (simple idea not actual structure)
Admin: Form Assignment, where you create what field you want your new Form to have
FrontEnd: Where the New form will be implemented (this is the root of this question)
FronEnd Storage: When the New form is filled out the data points are written to a set of tables
The idea is simple enough, Go into Admin, select the fields, fieldType, and Labels you want
I.E.
Field Name:*Enter a specific field name, like f_name or email
FieldType: [Text, TextArea, Password, Radio, DatePicker, CheckBox, Select, etc]
Label: What to display on the resulting form, f_name = First Name, etc
Then I hit a page on the FrontEnd where the New form is generated, I fill it out and voila the data is stored in the FrontEnd Storage tables.
So the question is, idea's on how to accomplish this, I already have the Admin section done, it's dynamically building and appropriately binding a frontEnd From that I would like advice on.
Currently my idea is to simply make a shell form that is a huge ugly switch statement that builds sfForm elements and appropriate validators for each field (fields given from what was entered in the Admin area)
I feel this is the 'wrong' way to do it, I did find a plugin 'spyFormBuilderInterface2Plugin' which is old and build for propel not doctrine, but this is the basic idea of what I am after. So how would YOU do it?
Please note I am not looking to Dynamically ADD forms to a current form, I can already do this and it's exactly what is implemented in my Admin section, I need to take data a create a whole NEW form programatically
I've created something like you described, just the way you said.
I have a model FormDefinition which defines a form, and has a collection of FormFields. Each form field has a widget_class, widget_options, validator_class and validator_options.
I have a custom myForm which needs a FormDefinition in it's constructor. In the setup() of myForm, I loop through all fields a instantiate the widgets and validators.
Beacuse in our solution, we needed/wanted to store all form data in separate tabels. My myForm extends from sfDoctrineForm, and my backend has some logic which creates/updates the (php) model and database definition, by just calling the appropriate Doctrine methods. But you could also create an EAV store.

How to make a field "autocomplete"?

I can't figure out how to make a field autocomplete in ATK.
I guess it has something to do with the type "reference" but still not sure.
Suppose I'm looking for a client name in a "line" type field, then the autocomplete should list me all/topXX matching names.
Scenario 1:
Once I hit [Enter] I'd need all that row from DB loaded in a form fields so I can edit the record.
I guess this requires getting the client ID first then posting to an "edit" page then calling "loadData()" method for that ID and populate fields.
Scenario 2:
I'm assignig a job request to a client. First I find the client then I could store its ID in a hidden field to be posted then.
Any advice?
TIA
I would suggest you to go with 2 forms. First form with a single field, and when field is changed it automatically reloads second form including the parameter.
You will also need an autocomplete field. Autocomplete is somewhat buggy in 4.0, but it have been polished up in 4.1 by using a technique in http://jqueryui.com/demos/autocomplete/#combobox
For use with models and controllers and also dropdown, example is here:
http://codepad.agiletoolkit.org/reloadform
Alternative example:
http://demo.atk4.com/demo.html?t=22
Since 4.1, you can also use autocomplete fields instead of reference:
$form1->addField('autocomplete','user');