drupal 6 forms type = select multiple = true... what is the returned value? - drupal-6

There doesn't seem to be any details about this in the forms api. So please forgive my question, but I need to know what is being returned when i submit values from a form field where I can select multiple values. I suspect it is an array, if so, how is it structured? Thanks.

Here is a dump of the value field from the $form_state variable after submission for a form that contains 2 multiple select lists. *Countries and Currencies. As you can see, you are correct, an array of values corresponding to the selected option values is returned for each of the 2 lists:
[values] => Array
(
[name] => PayPal
[ppid] => 17
[countries] => Array
(
[236] => 236
[237] => 237
)
[currencies] => Array
(
[USD] => USD
[EUR] => EUR
[CAD] => CAD
)
[submit] => Submit Details
[form_build_id] => form-d675700e434f656b0e1c7ac4aa91a210
[form_token] => 3405b88547c068a0f6a2742670b2149a
[form_id] => add_payment_method_form
[op] => Submit Details
)

Related

Which Association to add to get customfield added to tax

I am trying to get a customfield in an order inside of the price->calculatedTaxes object which I added to the tax entity.
I dont know what association I have to use to add the customfield to the object. The object is looking like this:
[price:protected] => Shopware\Core\Checkout\Cart\Price\Struct\CartPrice Object
(
[netPrice:protected] => 125.47
[totalPrice:protected] => 128.9
[calculatedTaxes:protected] => Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection Object
(
[elements:protected] => Array
(
[0] => Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTax Object
(
[tax:protected] => 0
[taxRate:protected] => 0
[price:protected] => 107.41666666667
[extensions:protected] => Array
(
)
)
[19] => Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTax Object
(
[tax:protected] => 3.43
[taxRate:protected] => 19
[price:protected] => 21.483333333333
[extensions:protected] => Array
(
)
)
)
This is my criteria for the orderdata:
$criteria->addFilter(new EqualsFilter('id', $orderId))
->addAssociation('deliveries')
->addAssociation('addresses')
->addAssociation('addresses.country')
->addAssociation('deliveries.shippingOrderAddress.country')
->addAssociation('orderCustomer.salutation')
->addAssociation('transactions.paymentMethod')
->addAssociation('lineItems')
->addAssociation('currency');
Is this even possible or am I completely wrong and this needs to be done completely different to add the customfield to that element?
Thanks
Danny
The CalculatedTax objects your are referring to are not at all direct descendants of the TaxEntity you added your custom fields to. These objects are constructed during runtime through a series of calls where only at the very beginning of the stack an instance of TaxEntity would be present.
There are quite a few levels in the stack between these two instances in fact. Without going into too much details, maybe have a look at the SalesChannelContextFactory where a TaxRuleCollection is stored in the current sales channel context. It has to happen this early on in the stack, since depending on the current user/customer different taxes may be applied, be it net/gross or different tax rates all together.
After all it depends on what you want to do with the data stored in the custom fields. If you need the data for altering the calculation of taxes you might want to store them early on with the creation of the sales channel context as an extension.

dump() only showing top level [duplicate]

I'm trying to use Twig (inside Symfony2) to debug a variable that contains a multidimensional array, yet it only outputs up to three arrays deep:
array
'Coating' =>
array
'type' => string 'single' (length=6)
'data' =>
array
0 =>
array
...
1 =>
array
...
2 =>
array
...
Whereas a print_r would generate
Array
(
[Coating] => Array
(
[type] => single
[data] => Array
(
[0] => Array
(
[id] => 1
[selectable] => 1
[name] => Front
)
[1] => Array
(
[id] => 7
[selectable] => 1
[name] => Back
)
[2] => Array
(
[id] => 13
[selectable] => 1
[name] => Both Sides
)
)
)
)
The reason I'd like Twig to do the debugging is that printing code prior to my template being rendered completely jumbles the output of a given page -- I'd like to print the data where it is easily read.
I don't understand why a "debug" would truncate data...
Edit: The debugging is through the use of {% debug foobar %} with that tag enabled through the inclusion of the following in my app's configuration:
services:
twig.extension.debug:
class: Twig_Extensions_Extension_Debug
tags: [ { name: 'twig.extension' } ]
I just read the source code of the twig debug extension (class Twig_Extensions_Node_Debug) and it doesn't truncate the var_dump. It is probably xdebug that is truncating: I cite a comment on the var_dump php.net documentation:
Keep in mind if you have xdebug installed it will limit the var_dump()
output of array elements and object properties to 3 levels deep.
To change the default, edit your xdebug.ini file and add the
folllowing line: xdebug.var_display_max_depth=n

Elasticsearch.NET search records starts with a value in a string field (NEST)

I have an issue for searching on elastic. I use NEST library for search and I try to get records that is customername field start with 'GÖKDEMİR' (for example)
var response = await _elasticClient.SearchAsync<AccountAddressInfo>(p => p
.Query(q => q
.MatchPhrasePrefix(m => m
.Field(f => f.CustomerName)
.Query(filter.CustomerName)
)
)
.Size(101));
With this search, I get the record on response that contains 'GÖKDEMİR' in customername field but I want to get fields starts with 'GÖKDEMİR'.
How can I do this.
In case your customername field is a term type, then you can try to use just Prefix where you are using MatchPhrasePrefix like so :
.Query(q => q
.Prefix(m => m
.Field(f => f.CustomerName)
.Query(filter.CustomerName)
)
)
.Size(101));

Solr - search multiple languages returning duplicates

I want to search across multiple languages (translations), but when I do duplicate results are returned for each language. I am using Drupal with Search API Solr for the indexing. The results look like the following:
[results] => Array
(
[3239/en] => Array
(
[id] => 3239/en
[score] => 1
[fields] => Array
(
[search_api_id] => 3239/en
[search_api_relevance] => 1
)
)
[3240/en] => Array
(
[id] => 3240/en
[score] => 1
[fields] => Array
(
[search_api_id] => 3240/en
[search_api_relevance] => 1
)
)
So the id and language are both contained in the key/id. Currently I can filter by a language using the code:
$index = search_api_index_load('default_multilingual_node_index');
$query = $index->query();
$query->keys($search_terms);
$filter = $query->createFilter('OR');
$filter->condition('search_api_language', $language);
$query->filter($filter);
$results = $query->execute();
I have been looking for a way (either Solr config, or Drupal Search API call) to be able to search across multiple languages without the duplicates to no avail. Are there any solutions?
Are you using the below modules
https://www.drupal.org/project/apachesolr_multilingual (for drupal 7)
https://www.drupal.org/project/search_api_solr_multilingual (for drupal 8)
Better support for non-English languages and support for multilingual search

Theming a node/add form in Drupal 6

I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php. I've added some DIV's so that I can have a two column node/add form, but now I'm trying to find print my fields, but can't seem to get it.
I'm basically using something like this:
<?php print form_render($form['field_sr_minutes']); ?>
which I came across on a Drupal Blog, but I get call to undefined function "form_render"
I am using the var_dump to get the the array below, how can I print my node title(subject) field without printing everything else? This way I can put each form field in the column I want Instead of the standard vertical drupal form.
Array
(
[0] => Array
(
[#type] => textfield
[#title] => Subject
[#required] => 1
[#default_value] =>
[#maxlength] => 255
[#weight] => -5
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => title
)
[#array_parents] => Array
(
[0] => title
)
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#input] => 1
[#size] => 60
[#autocomplete_path] =>
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => title
[#id] => edit-title
[#value] =>
[#defaults_loaded] => 1
[#sorted] => 1
)
Sorry. Because of your .tpl file name I thought that you were trying to theme a node view. For forms, the right function is not form_render but drupal_render. You can basically write things like echo drupal_render($form['field_sr_minutes']) . In the very end, remember to do a drupal_render($form) to render all the remaining things which you have not rendered by hand. This will be required to have the form working correctly.
Old Answer
The node.tpl.php and other content
type specific .tpl.php get passed the
full node object in $node. Try doing
a
drupal_set_message(print_r($node,TRUE))
on top of your tpl file. From that you
can figure out the exact path of the
values you need to print.
For example, title of the node will be
available in $node->title. However you
should be careful to always use
check_plain if you are going to
print user submitted values. For CCK
fields, you can find the already
filtered values in $node-><field
name>[0][view].

Resources