Currently, I'm working on Sylius framework. I need to override a few fields from Base models. It can be like changing field type, or changing field length, add null/not null/unique condition etc. How can we override this without touching core files Or ignoring existing fields and creating new fields with a similar name?
Not suggest to change the field type but create a new one.
But if you really want to make change, I guess should be similar to create a new field?
Have a check on the official doc:
http://docs.sylius.com/en/1.2/customization/model.html
Related
I am new to OrangeHRM 3.3.2 I need to add new field in the Personal Details. I need your help. Thanx
You can add fields to your OrangeHRM application by doing one of these.
1) Edit the database to contain your new field. Then edit the application form template using a new ohrm_widget (ohrm widget means an input field in the OrangeHRM system (ex. Test Field, Calendar, Dropdown, etc.)) and edit the controller function to pass your data to the backend. Then complete the DAO layer function to save your data at the database.
Ex:
If you are going to add a preferred name field for employees, then,
Add the preferred name column to the data table
Add the new preferred name input field to the form template
Add the new parameter in the controller layer to pass it to the backend
Complete the DAO layer function to save the preferred name parameter in the data table
2) In OrangeHRM 5.x you have the support from the application itself to create the custom fields for your entities. (I don't know about the 3.x versions.)
In buildForm() I would like to extract the full id/name of the current form field node. $builder->getName() returns only the name of the current node but I need the full property path, for example:
id="type_employments_0_location"
name="type[employments][0][location]"
Is there any way to generate this while building the form?
I'm working on a custom mandatory field type extension that looks up the "mandatoriness" of each field as the form is built; hence I need the full property path in buildForm() so that I can modify the options array.
From the FormConfigInterface, You should be able to use $builder->getPropertyPath().
It will return a PropertyPathInterface object, just use it as a string to get the real property path as string (i.e. print $builder->getPropertyPath() will give type[employments][0][location]).
Actually, it's pretty easy.
For every field type has many variables assigned.
<label for="{{ form.fieldname.vars.id }}">...</label>
From symfony doc (Form Variables Reference):
variables are common to every field type. Certain field types may have
even more variables and some variables here only really apply to
certain types.
Assuming you have a form variable in your template and you want to
reference the variables on the name field, accessing the variables is
done by using a public vars property on the FormView object.
Form Variables Reference
In a nutshell: The full property path generated by the form framework is not available to buildForm() but is available to buildView() and finishView(). Use those if you need access to the full property path.
My entity Person has a one to many relation with Tag entity. When creating a new person i'd like to show a textbox for assigning tag names separated by commas. User can then input an existent tag name or a new tag name (in this case, a new Tag entity is created and persisted).
Unfortunately entity field type has only checkbox and select representation. How can implement my own textbox representation?
You need to create a custom form type along with a custom data transformer.
This article is a pretty good guide on creating your own form type.
Also, check out Symfony's own source for the EntityType to get an idea of what's going on.
One way would be creating a custom data transformer.
I'm setting up a blog using Asp.net MVC3 and Entity framework 4. Most of the properties of the blog post already exist in the database, and therefore can easily be linked to the blog post during the creation.
One of the last element I've added are sources, these sources have a direct link to my BlogPost and have to be added during the creation of the BlogPost. My idea was to use the entity property Sources of the BlogPost entity, like:
blogPost.Sources.Add(new Source() { Name = source.Value, Url = source.Key.ToString(), Type = "source" });
Unfortunately I'm not allowed to create and add an Source this way, I'm getting the error: "Cannot insert explicit value for identity column in table 'Source' when IDENTITY_INSERT is set to OFF."
I guess this is cause of the ID column which has is an Identity with Identity increment turned on, but I don't set any ID myself. I tried to make id = null, but since its not a null-able it's not allowed either.
I believe turning this feature off let's me add records with my own ID's, but this is not what I want. The database should create the ID's.
Is there a way to add these kinds of properties during creation?
I solved the problem by adding the Source entity again from the database, apparently the entity framework model was generated before the field was set to Identity Increasing and therefore wanted to insert it's own ID's.
I have the following scenario:
My website db has a system table called "Companies", which includes an id field, companyName field, and companyImageUrl field.
How do I set up an umbraco document type for adding entries to this table ?
Maybe I shouldn't use a custom table at all ?
Thanks.
As far as I know, Umbraco doesn't support what you want to do out of the box (mapping a document type to a table that isn't part of the umbraco core).
One approach that might work is to create an action handler that syncs a Company doc type to your table when creating a node of that type.
It's a bit of a hack though. I've found that I've very rarely needed to create custom tables. What exactly are you trying to do with it? My guess is that you don't really need it and would be better off working with a doc type instead. Umbraco provides a variety of ways to get and act upon doc types from within custom C# code (check out the umbraco.NodeFactory namespace). You'll also get the added benefit of being able to easily interact with these nodes from XSLT/Razor.