How to edit an Array field in "Sonata Admin" with Symfony2 - symfony

With Symfony2, i use "FOSuserBundle". In my Entity "Group", i have an array column named "roles". this is "ArrayCollection" type. How to edit this field "roles" with Admin Generator like "Sonata Admin" when i want to create or edit "Group".
I try with "sonata_type_collection" type but no success.
Do you have an example or link who explain how to do this ?
PS: "roles" use "DC2Type:array" in Group table with MySQL.

WARNING EDIT: I'm not using Sonata anymore, #romain-bruckert comment might be better.
I think that you need to rely on the SonataAdmin field types :
array: display value from an array
boolean: display a green or red picture dependant on the boolean value, this type accepts an editable parameter to edit the
value from within the list or the show actions
date: display a formatted date. Accepts an optional format parameter
datetime: display a formatted date and time. Accepts an optional format parameter
text: display a text
trans: translate the value with a provided catalogue option
string: display a text
decimal: display a number
currency: display a number with a provided currency option
percent: display a percentage
choice: uses the given value as index for the choices array and displays (and optionally translates) the matching value
url: display a link
So for your ArrayCollection, an array type might be good.

Related

What argument format shall be passed to update_post_meta() in order to update a custom field of type PostObject?

Made a script for updating a wp post custom fields. All works fine for the fields with type text or number but a I have issues updating the field of type PostObject that contains a select list. Can not find any info on the format of the argument that must be passed to the update_post_meta() in order to update the selected value in the WP database of type PostObject.
For now the post id is static just for testing. And do not take into consideration the field name of the $_GET[] const. It is related to a other custom field. It is just given to see structure of the script.
My script test version I use tot change a specific custom field.
The select where I ge the value from. It returns a string.
Options of the field I want to change from user input.
Plugin name:
Found the solution with the trial and error method :-))).
So, in case you are modifying a custom field of type PostObject, you have to pass as the 'value' argument the ID of the post you want to be the new value of the custom field:
update_post_meta( 15896, 'specialita', '208' );
Thus, in this case the old post ID was for example 325 and and we replace it with a new post with the ID 208.

In a PDF, How to auto populate one field using other field text?

I have a 54 pages PDF file. In this PDF, I have some fields like Full Name, the Phone number, etc that repeats more than 10 times. How can do like When I enter Full name one time and all of the remaining full name fields can be filled automatically using Adobe Acrobat?
I hope I asked my question clearly. Thank you for your time and help.
The easiest is, when all properties of the field (font type, size, color, etc.) are the same, to simply copy the field to the other pages.
The field value is a so-called field level property, which will be the same for all instances of the field.
If you want to have only one place where the value can be entered, and the dependent fields should be read-only, you would have to have a different name for the entry field and display fields. In the entry field, you would then add the following line of code in either the Format or onBlur event:
this.getField("myDisplayFields").value = event.value ;
And that should push the value from the entry field to all fields named myDisplayFields.
And that's it…

Custom field data input wenzhixin/bootstrap-table

Hi! I want custom field data, because I have many arrays in one array.
I try using field: 'LeftNavigation.Title' but it didn't work.
You can't using multi Array data in field
Maybe you should choose another solution for this
Suggest : Create Leftnavigation Field , when click on this field it's show a second table show data from Leftnavigation array

getting textfield output partly unvisible

In a Drupal content type a need to get the output of a field partly unvisible. These are bank account details, the IBAN.
Normally the field shows 1234567. I need to get xxxx567. I need to show only the last 3 numbers/letters.
Also I need this output in field edit form.
On the display end you could change the output using a simple PHP function in the theme template by grabbing a substring of the field's last three digits and concatenating it with "xxxx" before printing.
You might also consider doing this at the formatter level by using the 'custom formatter' module perhaps?
https://drupal.org/project/custom_formatters
To do this on the edit screen is trickier. I suppose you could do a hook form alter to use PHP to change the field value, but I am afraid you will rewrite the field value when you save the node with the 'xxxx' instead of the real data.
I wonder if it would make sense to 1.) hide the actual field, 2.) create a dummy field that displays the text formatted as "xxxx567" to the user, and 3.) write some javascript that populates the hidden field with the visible field's value if it is changed. Presumably the form would still throw values if the hidden field did not meet formatting requirements.

Content(context)-related block in Drupal7

The case is following: I have a custom Content Type with a filed "data_field", for example. I want to have a block on a sidebar that will properly process and display data of this "data_field" field. How can I access that with Drupal API?
P.S. I understand that this problem can be solved with Views in some way, it has an ability of content-specific displaying, but I'm interested in the way it's achieved owing to API.
To render a field with the default Drupal settings for the content type:
$n = node_load($nid_of_content);
$n = node_view($n);
print render($n['field_somevalue']);
You can specify a node display format as well, eg
$n = node_view($n, 'teaser');
If you want to manipulate field content in a different way, use the raw field value:
$n = node_load($nid_of_content);
$value_you_want = $n->field_data_field_somevalue['und'][0]['value'];
This assumes you're not using any language/translation functionality - the 'und' stands for "undefined" and states that no language is has been explicitly set for the node.
If the field can contain multiple values, iterate through ['und'][0]['value'] to ['und'][x]['value']
The above code displays a raw value for most field types. Use print_r($n->field_somevalue) during development to find out what values are available to you; it depends on the field type. For example, file types give you 'uri' (among others) instead of 'value', text fields also have 'safe_value' which has input format filtering applied, long text fields will have 'summary' and 'safe_summary', &c.

Resources