Pre Process http://drupal8.ovh/en/tags/pre-process en Preprocess a Field, Change Theming of a field http://drupal8.ovh/en/tutoriels/210/preprocess-a-field-change-theming-of-a-field <span class="field field--name-title field--type-string field--label-hidden">Preprocess a Field, Change Theming of a field</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to remove the default date format option added by date module ?<br /> How to Change the Title, Change the description ("E.g., 29/07/2016") of the date widget ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 07/29/2016 - 17:13</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>For thah you must use an additional <span>process</span>.</p> <p>1. Create a custom module (<a href="/en/tutoriels/3/create-a-simple-module-for-drupal-8">Example</a> : Here we use <strong>mymodule</strong>)</p> <p>2. in the mymodule.module, add the hook <strong><span>hook_alter_element_info_alter</span></strong> and create a function '_mymodule_date_popup_process_alter'</p> <p>Ex:</p> <p><code>/**<br />  * implements hook_element_info_alter()<br />  *<br />  */<br /> function mymodule_alter_element_info_alter(&amp;$type) {<br />   if (isset($type['date_popup'])) {<br />     $type['date_popup']['#process'][] = '_mymodule_date_popup_process_alter';<br />   }<br /> }<br /> function _mymodule_date_popup_process_alter(&amp;$element, &amp;$form_state, $context) {<br />   unset($element['date']['#description']);<br />   if ($element['#name'] == 'node_changed') {<br />     $element['date']['#title'] = "The Date is";<br />   }<br />   return $element;<br /> }</code></p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/drupal-7" hreflang="en">Drupal 7</a></li> <li><a href="/en/tags/theming" hreflang="en">Theming</a></li> <li><a href="/en/tags/pre-process" hreflang="en">Pre Process</a></li> </ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=210&amp;2=comment&amp;3=comment" token="c9f67d78"></drupal-render-placeholder> </section> Fri, 29 Jul 2016 15:13:19 +0000 editor 210 at http://drupal8.ovh