Date mező alapértelmezett szövegének cseréje - avagy amikor kevés a _form_alter

  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.
Kategória: 
Leírás
Date mező alapértelmezett szövegének cseréje - avagy amikor kevés a _form_alter

Időnként agybajt lehet kapni a drupaltól, hogy ilyen pici apróság megváltoztatása, mint egy alapértelmezett szöveg a date modulban, mennyire bonyolult. Pedig nem az, csak sokszor kideríteni nehéz, hogy merre kell nyúlkálni, most is jó időbe telt, mire erre rájötten, még friss az élmény, úgyhogy levésem gyorsban.

Nos, a date mezővel nincs többé ilyen gond, lássuk mi a helyzet, amikor már kevés a hook_form_alter ahhoz, hogy egy form bizonyos beállításait megváltoztassuk.

Szóba jöhet egyébként preprocess és egyéb varázslás is, igen ám, de kizárólag a sminkrétegből nem érünk el olyan adatokat (például az egész $form tömb), amikre esetleg szükségünk van.

Itt jegyezném meg, ha netán valami zöldséget látnál, ne habozz kommentelni, a leírtak egy részét az elmúlt órákban szedtem össze.

Nézzünk be először picit a form api mögé. Ahogy az a form apiban meg van írva, ahhoz, hogy egy form elemet a drupal kirajzoljon, meg kell adni az elem típusát, hogy például checkbox, radio vagy sima szöveges mező kell a formra. Ezekkel mindenki találkozott már, aki valaha kódból készített formot, netán hook_form_alterrel befolyásolt egy-egy elemet.

Nos, ezek az elemtípusok drupalban az ún. element-ek. A drupal saját maga is definiál egy csomó elementet (legyen már ezek után formelem típus, mert összeakad a nyelvem, ahogy hangosan olvasom..), ezek azok, amik a form api referenciaoldalán találhatók a táblázat fejlécében.

Íme egy példa a core-ból:

[geshifilter-drupal6]$types['button'] = array( '#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#limit_validation_errors' => FALSE, '#process' => array('ajax_process_form'), '#theme_wrappers' => array('button'), );[/geshifilter-drupal6]

Ezeket a formelem típusokat a hook_element_info() függvény implementálásával lehet deklarálni. Látszik, hogy sok default értéket lehet hozzákapcsolni, saját validációs függvényt, sminkfüggvényt, feldolgozófüggvényt stb.

Na és itt jön a képbe a date modul. Az a kis szemét nem átallott saját elemtípust készíteni, és természetesen jó mélyen belekódolta azt szöveget, amit nekünk le kell cserélni. Na és vajon hogyan lehet beleszólni vajon a hook_element_info()-ban deklarált változókba? Naná, hogy a hook_element_info_alter() megvalósításával.

Amúgy ha kiváncsiak vagyunk, hogy milyen elemtípusok vannak a rendszerünkben, csináljuk meg ezt, lesz ám meglepi:

[geshifilter-drupal6]function MODULNEVE_element_info_alter(&$type) { dsm($type); }[/geshifilter-drupal6]

Akkor vissza a date elemtípushoz: Ő deklarál magának egy #process függvényt, amivel a sminkfüggvényéhez készíti elő az adatokat. Nos, az sehol nincsen megszabva, hogy egyetlen #process függvényünk legyen, csapjuk tehát hozzá a sajátunkat, és módosítsuk azt, ami nekünk kell:

[geshifilter-drupal6] /** * Implementation of hook_element_info_alter(). */ function MODULNEVE_element_info_alter(&$type) { if (isset($type['date_text'])) { //We need a custom process function to modify some text $type['date_text']['#process'][] = 'MODULNEVE_text_element_process'; } } /** * Modify default description was set in date date_text process * * @param array $element * @return array * the timezone form element * * @see date_text_element_process($element, $form_state, $form) */ function MODULNEVE_text_element_process($element, $form_state, $form) { //Itt bújt el a description $element['date']['#description'] = ' ' . t('Format: mm/yyyy (eg. @date)', array('@date' => date_now()->format($element['#date_format']))); return $element; }[/geshifilter-drupal6]

Igazából ennyi az egész. Igen ám, de honnan tudjam meg, hogy éppen nekünk az hook_element_info_altert kell bántani? Hát ez egy marha jó kérdés.. Én most úgy csináltam, hogy fogtam a devel_themert, belekattintok a legbelső form elemre, és elkezdtem a devel_themer ablakában visszafelé lépkedni a függvényeken. Aztán vagy rájövök valamire, vagy nem..

Előtte persze próbálkoztam hook_form_alterben debugolni, de ott sem találtam értelmeset. Talán ott érdemes megfogni, hogyha form_alterben egy legbelső elem #type értéke valami egzotikus, akkor érdemes megnézni az emlegetett hook_element_info_alterben.

Hozzászólások

Thanks for sharing such a

Thanks for sharing such a nice thinking, article is good, thats why i have read it fully|

Excellent post. I was

Excellent post. I was checking constantly this blog and I am impressed! Very useful information specially the last part :) I care for such info a lot. I was looking for this particular information for a very long time. Thank you and good luck.|

I'm gone to say to my little

I'm gone to say to my little brother, that he should also pay a visit this website on regular basis to get
updated from most recent reports.

Write more, thats all I have

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why waste your intelligence on just posting videos to your weblog when you could be giving us something informative to read?|

Good way of explaining, and

Good way of explaining, and good paragraph to obtain data regarding my presentation subject, which i am going
to convey in college.

My family always say that I

My family always say that I am wasting my time here at net, except I know I
am getting experience all the time by reading such pleasant content.

Very good article! We will be

Very good article! We will be linking to this particularly great article on our website.
Keep up the great writing.

Excellent post. I was

Excellent post. I was checking continuously this blog and I am impressed! Very useful info specially the last part :) I care for such information much. I was seeking this particular info for a very long time. Thank you and good luck.|

It's hard to come by

It's hard to come by knowledgeable people about this subject, but you sound like you know what you're talking about! Thanks|

Fantastic beat ! I wish to

Fantastic beat ! I wish to apprentice even as you amend your web site, how could i subscribe for a blog website? The account helped me a applicable deal. I had been tiny bit acquainted of this your broadcast provided vivid transparent idea|

Hmm is anyone else having

Hmm is anyone else having problems with the pictures on this blog loading? I'm trying to determine if its a problem on my end or if it's the blog. Any feedback would be greatly appreciated.|

I have been browsing on-line

I have been browsing on-line more than three hours today, but I by no means discovered any interesting article like yours. It is lovely price sufficient for me. Personally, if all web owners and bloggers made excellent content as you did, the internet will probably be much more helpful than ever before.|

Nice post. I was checking

Nice post. I was checking continuously this weblog and I'm impressed! Extremely helpful info specifically the remaining part :) I take care of such information a lot. I was seeking this particular info for a very long time. Thank you and best of luck. |

Every weekend i used to go to

Every weekend i used to go to see this web site, for the reason that i want enjoyment, for the reason that this this web site conations actually good funny data too.|

Nice post. I was checking

Nice post. I was checking continuously this blog and I am impressed! Extremely useful info specially the last part :) I care for such information a lot. I was looking for this certain information for a long time. Thank you and good luck.|

I'm really inspired along

I'm really inspired along with your writing talents and also with the layout to your weblog. Is this a paid topic or did you modify it your self? Either way keep up the nice quality writing, it is uncommon to see a nice blog like this one nowadays..|

Woah! I'm really digging the

Woah! I'm really digging the template/theme of this site. It's simple, yet effective. A lot of times it's difficult to get that "perfect balance" between usability and visual appearance. I must say you have done a superb job with this. Also, the blog loads extremely quick for me on Safari. Excellent Blog!|

Raiding our own crawl space a

Raiding our own crawl space a day, crafted {us|all of us|us all|people|you|united states|individuals|usa|you and me|everyone|u .

Do you have a spam problem on

Do you have a spam problem on this site; I also am a blogger, and I was wanting to know your situation; many of us have created some nice methods and we are looking to trade strategies with other folks, be sure to shoot me an email if interested.|

Does your site have a contact

Does your site have a contact page? I'm having trouble locating it but, I'd like to send you an e-mail. I've got some ideas for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.|

g|consequently|meaning|one

g|consequently|meaning|one thing about this|you can actually} it is usually dissolved in unwanted weight.

You really make it appear

You really make it appear really easy with your presentation but I to find this topic to be actually something that I think I'd never understand. It sort of feels too complicated and very vast for me. I am looking forward in your next publish, I will try to get the hang of it!|

I do agree with all of the

I do agree with all of the concepts you've presented for your post. They're very convincing and will definitely work. Still, the posts are too short for starters. May just you please prolong them a little from subsequent time? Thank you for the post.|

s .} upright.

s .} upright.

I am truly grateful to the

I am truly grateful to the holder of this web page who has shared this fantastic piece of writing at at this place.|

hello there and thank you for

hello there and thank you for your information – I have certainly picked up anything new from right here. I did however expertise several technical points using this site, since I experienced to reload the website many times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I'm complaining, but sluggish loading instances times will often affect your placement in google and can damage your quality score if ads and marketing with Adwords. Anyway I am adding this RSS to my e-mail and could look out for a lot more of your respective exciting content. Ensure that you update this again very soon.|

The concept that these

The concept that these particular manners are immoral or even, actually, prohibited for no reason inputs the particular Machiavellian's thought process.

Hello all, here every person

Hello all, here every person is sharing such knowledge, thus it's pleasant to read this website, and I used to visit this web site daily.|

I have fun with, lead to I

I have fun with, lead to I found just what I was taking a look for. You've ended my 4 day long hunt! God Bless you man. Have a nice day. Bye|

The software?ersus

The software?ersus particularly crucial to grasp the real difference amongst absence of libido not to mention men's, or simply {ED|Erectile dysfunction|Male impotence|Impotence|Impotence problems|Edward|Erection dysfunction|Edward cullen|E|Education|E .

Please let me know if you're

Please let me know if you're looking for a author for your blog. You have some really good articles and I believe I would be a good asset. If you ever want to take some of the load off, I'd absolutely love to write some articles for your blog in exchange for a link back to mine. Please shoot me an email if interested. Cheers!|

Every weekend i used to visit

Every weekend i used to visit this site, because i wish for enjoyment, since this this web page conations really nice funny material too.|

Contrary to all the Recreate

Contrary to all the Recreate of Evangelion, despite the fact that, A Nautilus History isn't well-known, simply because it simply is present regarding Malay LD together with VHS; and they also just weren't theatrically allocated often.

I have fun with, result in I

I have fun with, result in I found exactly what I was taking a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye|

I simply couldn't go away

I simply couldn't go away your web site before suggesting that I really enjoyed the standard information an individual supply for your visitors? Is gonna be again often in order to inspect new posts|

I've learn some good stuff

I've learn some good stuff here. Certainly value bookmarking for revisiting. I surprise how a lot attempt you set to create one of these magnificent informative website.|

Heya i am for the primary

Heya i am for the primary time here. I found this board and I in finding It truly useful & it helped me out much. I am hoping to offer one thing back and help others such as you aided me.|

If you wish for to take a

If you wish for to take a good deal from this paragraph then you
have to apply these strategies to your won weblog.

When someone writes an

When someone writes an paragraph he/she maintains the plan of a user in his/her mind that how a user can understand it. So that's why this article is great. Thanks!|

This information is worth

This information is worth everyone's attention. How can I find out more?|

What's up, yeah this article

What's up, yeah this article is genuinely pleasant and I have learned lot of things from it regarding
blogging. thanks.

Wow! After all I got a

Wow! After all I got a website from where I can actually take useful data regarding my study and knowledge.|

Excellent weblog right here!

Excellent weblog right here! Also your web site lots up very fast! What host are you the use of? Can I am getting your associate hyperlink in your host? I wish my website loaded up as fast as yours lol|

I know this if off topic but

I know this if off topic but I'm looking into starting
my own blog and was curious what all is needed to get set up?
I'm assuming having a blog like yours would cost a pretty penny?
I'm not very internet savvy so I'm not 100% positive.
Any recommendations or advice would be greatly appreciated.
Thank you

Have you ever thought about

Have you ever thought about publishing an e-book or guest authoring on other sites? I have a blog based on the same topics you discuss and would really like to have you share some stories/information. I know my readers would value your work. If you're even remotely interested, feel free to shoot me an e mail.|

Incredible points.

Incredible points. Outstanding arguments. Keep up the great effort.|

I am sure this post has

I am sure this post has touched all the internet people, its really really
pleasant article on building up new weblog.
Jim's San Jose Carpet Cleaning
780 S 3rd St, San Jose, CA 95112
3408-351-1063
colettemackie2641 [at] gmail [dot] com

It's really a great and

It's really a great and useful piece of information. I am happy that you shared this helpful info with us. Please stay us informed like this. Thanks for sharing.|

Greetings from California!

Greetings from California! I'm bored to tears at work so I decided to browse your blog on my iphone during lunch break. I really like the information you provide here and can't wait to take a look when I get home. I'm surprised at how fast your blog loaded on my mobile .. I'm not even using WIFI, just 3G .. Anyways, awesome site!|

Piece of writing writing is

Piece of writing writing is also a excitement, if
you be acquainted with then you can write if not it is complex to write.

Hozzászólás

A mező tartalma nem nyilvános.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Engedélyezett HTML elemek: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • A webcímek és email címek automatikusan linkekké alakulnak.
  • A sorokat és bekezdéseket a rendszer automatikusan felismeri.
  • Engedélyezett HTML elemek: <a> <blockquote> <br> <cite> <code> <dd> <del> <div> <dl> <dt> <em> <li> <ol> <p> <span> <strong> <ul>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <sql>. The supported tag styles are: <foo>, [foo].
  • Minden email cím át lesz alakítva ember által olvasható módon, vagy (ha a JavaScript engedélyezett) ki lesz cserélve kattintható, de biztonságos hivatkozásra.