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.
  • 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

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.|

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.

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.

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

The thing is that this has

The thing is that this has always been the case with any sort of committee on any sort of subject from something as minor as putting the Government of
Canada logo on signs or what not to something as major as this as for how the committee has been shaped or what witnesses have

This article is genuinely a

This article is genuinely a nice one it assists new net people,
who are wishing in favor of blogging.

What's up to every , for the

What's up to every , for the reason that I am really keen of reading this
webpage's post to be updated daily. It contains good information.

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; we have
created some nice procedures and we are looking to exchange techniques with
other folks, please shoot me an email if interested.

Howdy! This post could not be

Howdy! This post could not be written any better!
Reading through this post reminds me of my previous room mate!

He always kept talking about this. I will forward
this page to him. Fairly certain he will have a good read.
Thanks for sharing!

I do trust all of the ideas

I do trust all of the ideas you've introduced on your post. They are very convincing and can certainly work. Nonetheless, the posts are too brief for beginners. May you please prolong them a little from subsequent time? Thanks for the post.|

Yes! Finally someone writes

Yes! Finally someone writes about medical doctor.

Hey! I'm at work surfing

Hey! I'm at work surfing around your blog from my new apple iphone!
Just wanted to say I love reading through your blog and look forward to all your posts!
Keep up the great work!

I know this web page gives

I know this web page gives quality dependent content and additional data, is there any other site which gives these kinds of stuff in quality?|

I was pretty pleased to

I was pretty pleased to uncover this great site. I want to to thank you for ones time
due to this fantastic read!! I definitely really liked every part of it and i also have
you bookmarked to see new information on your website.

Great blog you have here..

Great blog you have here.. It's difficult to find high quality
writing like yours these days. I truly appreciate people
like you! Take care!!
Jay's Santa Clarita Tree Removal Kings
26174 Las Lanas Ct, Santa Clarita, CA 91355
661-464-1270
laureljefferson09875 [at] gmail [dot] com

I'll immediately grab your

I'll immediately grab your rss feed as I can not in finding
your email subscription link or e-newsletter service. Do you have any?
Please let me recognise so that I may just subscribe. Thanks.

Very nice post. I just

Very nice post. I just stumbled upon your blog and wanted
to say that I've truly enjoyed surfing around your blog posts.

After all I'll be subscribing to your feed and I hope you write
again soon!

Great article. FlexBuild

Great article.

FlexBuild Huntington Beach Concrete Company
2520 Florida St, Huntington Beach, CA 92648
714-410-5374
suzannaweiss98719 [at] gmail [dot] com

Hello! This is kind of off

Hello! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about creating my own but I'm not sure where to begin. Do you have any ideas or suggestions? Many thanks|

I am not sure where you're

I am not sure where you're getting your information, but great topic.

I needs to spend a while learning more or working out more.
Thank you for excellent information I used to be in search of this information for my mission.

hey there and thank you for

hey there and thank you for your information – I have definitely picked up something new from right here.
I did however expertise some technical points using this website, since I experienced to reload the
web site a lot of times previous to I could get it to load properly.
I had been wondering if your hosting is OK? Not that I am complaining, but
sluggish loading instances times will very frequently affect your placement in google and can damage your high-quality score if ads and marketing with Adwords.

Well I am adding this RSS to my e-mail and can look out for a lot
more of your respective intriguing content. Make sure you update this again very soon.

It's a pity you don't have a

It's a pity you don't have a donate button! I'd without a doubt donate to this brilliant blog!
I suppose for now i'll settle for book-marking and adding your RSS feed to my Google account.
I look forward to fresh updates and will talk about this site
with my Facebook group. Chat soon!

Excellent way of explaining,

Excellent way of explaining, and pleasant
paragraph to take facts regarding my presentation subject matter, which i am going to convey
in academy.

Thanks a lot for sharing this

Thanks a lot for sharing this with all of us you really know what you're speaking about!

Bookmarked. Please additionally visit my web site =).
We may have a hyperlink alternate agreement among us

Anaheim Divorce Lawyers in Practice
204 S Illinois St, Anaheim, CA 92805
714-410-5333
sabihafelix09835 [at] gmail [dot] com

I know this if off topic but

I know this if off topic but I'm looking into starting my own weblog 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 web savvy so I'm not 100% certain. Any tips or advice would be greatly appreciated. Thank you|

I'm extremely impressed with

I'm extremely impressed with your writing skills as well as with the layout on your weblog.
Is this a paid theme or did you modify it yourself? Anyway keep up the
excellent quality writing, it is rare to see a nice blog like this one nowadays.

This piece of writing is in

This piece of writing is in fact a nice one it assists new net viewers, who
are wishing in favor of blogging.

No matter if some one

No matter if some one searches for his essential thing,
therefore he/she needs to be available that in detail, so that
thing is maintained over here.

Good day I am so grateful I

Good day I am so grateful I found your weblog,
I really found you by mistake, while I was researching on Yahoo
for something else, Nonetheless I am here now and would just like to
say many thanks for a tremendous post and a all round
entertaining blog (I also love the theme/design), I don’t have time
to browse it all at the minute but I have bookmarked it and also
added in your RSS feeds, so when I have time I will be
back to read a great deal more, Please do keep up the excellent work.

Jay's Santa Clarita Tree Removal Kings
26174 Las Lanas Ct, Santa Clarita, CA 91355
661-464-1270
laureljefferson09875 [at] gmail [dot] com

Thanks for sharing such a

Thanks for sharing such a good opinion, paragraph is nice,
thats why i have read it fully

It's not my first time to pay

It's not my first time to pay a visit this web site, i am browsing this site dailly and take nice information from here every day.|

Hi there to all, the contents

Hi there to all, the contents existing at this web page are actually awesome
for people knowledge, well, keep up the nice work fellows.

Hi! I could have sworn I've

Hi! I could have sworn I've been to this website before but after
looking at many of the articles I realized it's new to me.

Anyhow, I'm definitely delighted I came across it and I'll be book-marking it and checking back regularly!

Hello mates, fastidious

Hello mates, fastidious paragraph and good arguments commented at
this place, I am truly enjoying by these.

There is certainly a lot to

There is certainly a lot to find out about this topic. I love all of the points you've made.|

It's wonderful that you are

It's wonderful that you are getting thoughts from this article as well
as from our dialogue made at this time.

If some one wishes expert

If some one wishes expert view regarding blogging then i suggest him/her to pay
a visit this website, Keep up the fastidious job.

Hi my family member! I wish

Hi my family member! I wish to say that this article is awesome,
great written and include almost all important infos.
I'd like to see more posts like this .

Hello, I think your website

Hello, I think your website might be having browser compatibility issues.

When I look at your blog site in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping.
I just wanted to give you a quick heads up! Other then that, superb blog!

Wonderful beat ! I wish to

Wonderful beat ! I wish to apprentice while you amend your website, how could i subscribe for a
blog web site? The account helped me a acceptable deal.
I had been a little bit acquainted of this your broadcast offered
bright clear concept

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 site when you could
be giving us something enlightening to read?

Hello, I want to subscribe

Hello, I want to subscribe for this web site to obtain most up-to-date updates, therefore where can i do it please assist.

Hey I know this is off topic

Hey I know this is off topic but I was wondering
if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with
something like this. Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to your new
updates.

Hey! I just wanted to ask if

Hey! I just wanted to ask if you ever have any issues with hackers?

My last blog (wordpress) was hacked and I ended up losing months of hard work due to no
data backup. Do you have any methods to prevent hackers?

Jim's San Jose Carpet Cleaning
780 S 3rd St, San Jose, CA 95112
3408-351-1063
colettemackie2641 [at] gmail [dot] com

I am sure this paragraph has

I am sure this paragraph has touched all the internet visitors, its
really really good post on building up new webpage.

Hello to every one, it's in

Hello to every one, it's in fact a fastidious for
me to visit this website, it contains valuable Information.

Hey! I realize this is

Hey! I realize this is somewhat off-topic however I had to ask. Does running a well-established website like yours require a lot of work? I am completely new to operating a blog however I do write in my diary daily. I'd like to start a blog so I can share my experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners. Appreciate it!|

Hello everyone, it's my first

Hello everyone, it's my first pay a visit at this site,
and paragraph is really fruitful for me, keep up posting these posts.

That is really fascinating,

That is really fascinating, You're an overly professional blogger.
I've joined your rss feed and sit up for in search of extra of your great post.
Also, I have shared your web site in my social networks

Thanks for every other great

Thanks for every other great article. The place
else could anyone get that type of info in such an ideal means of writing?
I've a presentation next week, and I am on the look for such info.

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.