Use Devel and kint ,
and search Kint
NOTE: Please make sure devel profile must be kint
ksm($form); // print the form with search option in kint
1 - $form_state->getValues(); // Shows all the form field value
2 - $form_state->getUserInput(); //to get the user input including buttons clicked
+++++++++++++++++++++++
dump(_context|keys) }} // in twig file
in twig file :
{{ kint(form['#custom_data'].custom_form_id) }}
ksm($form['actions']['delete']['#url']->getOptions()['entity']->toArray());
and search Kint
NOTE: Please make sure devel profile must be kint
ksm($form); // print the form with search option in kint
1 - $form_state->getValues(); // Shows all the form field value
2 - $form_state->getUserInput(); //to get the user input including buttons clicked
+++++++++++++++++++++++
dump(_context|keys) }} // in twig file
- Compare string in Twig file
{% set form_id = form.custom_data.form_id %}
{% if form_id == "node_story_edit_form" %}
Yes i am here
{% endif %}
2 - get the # valued of form in twig templates, :
All the array and object value can get by dot(.) operation while # value get by direct array like below,
if($form['#form_id'] == 'node_video_form' || $form['#form_id'] == 'node_video_edit_form'){
$form['#custom_data'] = array('custom_form_id' => $form['#form_id']);
ksm($form);
}
2 - get the # valued of form in twig templates, :
All the array and object value can get by dot(.) operation while # value get by direct array like below,
if($form['#form_id'] == 'node_video_form' || $form['#form_id'] == 'node_video_edit_form'){
$form['#custom_data'] = array('custom_form_id' => $form['#form_id']);
ksm($form);
}
in twig file :
{{ kint(form['#custom_data'].custom_form_id) }}
How to get the value (or use the function )within the class :
I am printing the ksm($form['actions']['delete']['#url']->getOptions()['entity']); in form alter module,
and get the output as below ,
Motive it , how to get the values of node field like, vid,languagecode
if we got anywhere the namespace or class name , then we can call the function directly after it
here, Drupal\node\entity\Node All the function will work like a charm,
So I am using the $node->toArray(),
ksm($form['actions']['delete']['#url']->getOptions()['entity']->toArray());
Now i got the Array value of all the fields,
Get Current Date With Format Drupal-8:
$current_timestamp = \Drupal::time()->getCurrentTime();
$format_date = \Drupal::service('date.formatter')->format($current_timestamp, 'custom', 'Y-m-d H:i:s', '','');
Comments
Post a Comment