Gravity Form hidden field not being sent - gravity-forms-plugin

I am adding a hidden field in my gravity forms using "gform_pre_render" filter and later on I add a value in it using jQuery.
$props = array(
"id" => "9999",
"label" => "Hidden value",
"type" => "hidden",
"cssClass" => "my_hidden_value
);
$field = GF_Fields::create( $props );
The input is added as expected on the form. The only issue I have is that I cannot acces it using "gform_after_submission" action.
All paramteres are in the $entry, except my hidden field.
Anyone had this issue before?
Thanks

See this bit from the gform_pre_render docs:
This filter should be used in conjunction with the gform_pre_validation, gform_pre_submission_filter, and gform_admin_pre_render filters to update the to be able to use those values elsewhere (merge tags in the confirmation and notification, for example).
Hope it helps. :)

Related

How do I hide a drupal 8 form element on default

I am trying to do something that should be extremely easy in drupal. I just want to simply hide a form field in the drupal admin by default.
Making the field disabled simply doesn't work. I cannot find any documentation for this. It's unbelievable that it's this hard to do something so simple in Drupal.
$form['field_name']['#states'] = [
'visible' => [
':input[name="field_foo[0][target_id]"]' => ['value' => 'blah'],
],
'invisible' => true,
];
The visible part works. If another field has a certain value, then show the form element.
But I simply cannot get it to hide this field on default when you're adding a new node.
Add into form element array $element = ['#access' => FALSE,]:
$form['field_name'] = [
'#access' => FALSE,
]
Easy and does not affect your default value (if default is set):
$form['field_name']['#attributes']['class'][] = 'hidden';
Drupal core will "display: none;" this element from core styles using the 'hidden' css class.
You don't need to set invisible, it will be hidden by default unless the visible condition is met. Also the input looks to be wrong, as it should be whatever the name attribute is set to in the element you are basing the condition on.
The drupal.org documentation with an example.
e.g.
$form['field_name']['#states'] = [
'visible' => [
':input[name="field_conditional_on"]' => ['value' => 'value_conditional_on'],
],
];
Or if you just want to hide it using CSS's display property, you could use something like below,
$form['field_name']['#states'] = [
'#attributes' => array('style' => array('display: none;')),
];

Codeigniter form - hidden field not filled with variable

I'm having a little problem regarding a CI Form:
I retrieve some entries from the db and put them in hidden fields in my form. One of the values isn't filled into the hidden field, even though I can verify it's there:
<?php
echo $grno;
echo $dsca;
$hidden = array(
'grno' => $grno,
'dsca' => $dsca,
'bsex' => 'männlich',
'noch' => '0',
....
the echo statement shows both values in the view but the hidden field that is supposed to be filled with the value of $grno is empty..
Any ideas?
Thanks a lot, this is driving me crazy...
Regards
Lutz

Drupal 8 - Entity Reference - Autocomplete - Add fields to search and result in autocomplete

I have an entity called "lawyers."
And another entity refers to lawyers.
The problem is that when searching the reference field with the autocompletion system many repeated names appear:
Pablo
Pablo
Pablo
Pablo
I need the reference field to be able to show the surnames of that person so that it turns out to be
Pablo Martínez
Paglo Gutirerrez
Pablo Iglesias
Pablo López
how can I do this?
You will have to create a Entity Reference View to use as handler for doing the autocomplete lookup. Then you can add additional fields (such as last name) to the autocomplete results. This article outlines that process well enough:
https://www.cmsminds.com/blog/entity-reference-entity-reference-view-in-drupal-8/
If the field is a base field and is not available on the Manage form Display page, you will have to modify the entity class Lawyer::baseFieldDefinitions function. Specifically, you need to change the handler and set the form display settings. In your BaseFieldDefinition::create call:
->setSetting('handler', 'default')
Needs to change to this:
->setSetting('handler', 'views')
->setSetting('handler_settings', [
'view' => [
'view_name' => 'name_of_entity_reference_view',
'display_name' => 'name_of_view_display',
],
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 2,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
Alternatively, if you want to make base fields available in the UI, you can use this line to make the field available in the form display settings ui (and then export your form display settings as config:
->setDisplayConfigurable('form', TRUE);

display radio buttons using FormHelper

I am using CakePHP3
I am unable to decipher the documentation on using radio buttons to create for a list of results.
There is create radio button.
Which I tried this way:
foreach ($userGroups as $group_id => $group) {
echo $this->Form->radio("UserGroup.$group_id.id", ['value' => $group_id, 'label' => $group]);
}
There is using select pickers.
Which says all you need to do is set the type to radio. But I checked the api and it looks like it will unset the type.
Anyway, I tried
echo $this->Form->select("user_circle_id", $userGroups, ['type' => 'radio']);
Nothing works.
Please advise.
UPDATE:
$userGroups = [1 => 'Group 1', 2 => 'Group 2']; // basically primary key is keys and the display fields are the values.
Use following syntax :
$selectedStatus = 1;
$attributes = array('legend'=>false,'value'=>$selectedStatus,'class'=>'sortByStatusCourse','name'=>'sortByStatusCourse');
$options = array("1"=>"Active","0"=>"Inactive");
echo $this->Form->radio('is_active', $options,$attributes);
Code explanation :
We are passing parameters to cakePHP core so that it will output Radio button in HTML.
echo $this->Form->radio :
Here 1st param is Name on field in Database. 2nd param is What are the options for radio buttons , its value and text .3rd param is what are its attributes like what should be its default value here I explicitely set it to 1 so it will already tick radio with Activetext.
According to your code : echo $this->Form->radio("UserGroup.$group_id.id", ['value' => $group_id, 'label' => $group]);
I think order of param is wrong as you pass VALUE in 2nd param which should be 3rd param.Check my code.

zfdatagrid and jqgrid: subgrid is not loading

I am using Zend Framework that's why I decided to use "zfdatagrid deploy jqgrid" instead of using jqgrid straight away.
I want to have jqgrid with subgrid. Grid is shown ok, but when I click expand button then I get notice "Loading" but nothing happens. I have debugged that "subGridUrl" is called correctly, because debugger hit function where I should select data from MySQL for subgrid, and I tried to pass pure json response (instead of selecting from MySQL) but still subgrid is not shown. Maybe I don't understand what response must be? My response:
<...>
$responce = new stdClass();
$responce->rows[0]['id']='0';
$responce->rows[0]['cell']=array('0','test1','123','1');
$responce->rows[1]['id']='1';
$responce->rows[1]['cell']=array('1','test2','321','2');
$j = json_encode($responce);
echo $j;
<...>
Sorry, my bad. But instead of deleting my question, I will explain my mistake incase somebody else will do the same...
I made a mistake declaring "subGridModel". Instead using array:
$jqGrid->setJqgParams(array(
'caption' => 'test report',
<..>
'subGrid' => true,
'subGridUrl' => $this->view->url(array('controller'=>'report','action'=>'indexstoragebalancesubgrid'),'default', true),
'subgridtype' => 'json',
'loadonce' => false,
// next line where problem fixed
'subGridModel' => array(array("name" => array("ID", "Title", "Code", "Quantity"), "width" => array(10,55,200,80)))
<..>
));
I wrote string:
'subGridModel'=>'[{name : ["ID", "Title", "Code", "Quantity"], width : [10,55,200,80]}]'
And that's why it did not work in javascript.
By the way, you can see that I wrote array in array. That is because with one array ZFDataGrid generates such javascript:
"subGridModel":{"name":["ID","Title","Code","Quantity"],"width":[10,55,200,80]}
instead of this:
"subGridModel":[{"name":["ID","Title","Code","Quantity"],"width":[10,55,200,80]}]
It is important for jqgrid subgrid to work!