MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Jul 05, 2009, 09:14 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search via SMF
or Google:
modx forums
all of modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Read
Frequently Asked Questions (FAQ)
MODx Community Forums
»
Add-ons, Extensions & Elements
»
Forms, Form Processing & Anti-Spam
»
eForm
(Moderator:
TobyL
)
»
Can I Use eform to process form fields injected into the DOM with Javascript?
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: Can I Use eform to process form fields injected into the DOM with Javascript? (Read 569 times)
0 Members and 1 Guest are viewing this topic.
therebechips
Sr. Member
Posts: 305
Can I Use eform to process form fields injected into the DOM with Javascript?
«
on:
Dec 22, 2008, 05:05 AM »
Is it possible for eform to be set up to validate form elements that are injected into the DOM by javascript? I'm guessing I'd need to amend the form template chunk on the fly using an eform event, or a custom snippet that runs eform using $modx-runSnippet() ?
This is the kind fo thing I need to achieve:
Code:
<!--hardcoded markup-->
<input name="name1" id="name1" type="text" value="[+name1+]" eform="Name1::1:"/>
<!--injected markup-->
<input name="name2" id="name2" type="text" value="[+name2+]" eform="Name2::0:"/>
The injected markup would always be a copy of an existing section of hardcoded markup, but with an incrementing trailing index, eg name1, name2, name3.
Going on from the initial validation of this data, I also want to be able to store the data in a database and then retrieve it and repopulate the form. And I should also mention that this would be a multi-page form with a branching.
Is eform the best tool for this or should I write a custom class? If so, can anyone point me to a super flexible form handling library that works nicely with modx? If anyone has ever done anything like this I'd love to hear the details.
Thanks!
Mark
Logged
mrhaw
Committed to MODx
Posts: 1,087
modx == freedom
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #1 on:
Dec 22, 2008, 05:23 AM »
I know nothing but I read this in the wiki:
Quote
Hidden fields
By default hidden fields are validated as a protection against tampering by comparing the input against the value set in the form template (much like the select, checkbox and radio fields) In some circumstances this may not be desirable however. For instance when you use some javascript in your form to store a result in a hidden field. In those cases you can turn this behaviour off by setting the eform attribute (with or without it's own validation).
This is another way of form validation --->
http://modxcms.com/forums/index.php/topic,30540.msg185573.html#msg185573
«
Last Edit: Dec 22, 2008, 05:38 AM by mrhaw
»
Logged
My playground:
http://4up2date.info
| Host: (mt) Media Temple (gs) | Server: Apache 2.0 | MySQL 4.1.11 | PHP 5.2.6 | MODx 0.9.6.3 (patchwork)
therebechips
Sr. Member
Posts: 305
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #2 on:
Dec 22, 2008, 05:47 AM »
Quote
This is another way of form validation --->
http://modxcms.com/forums/index.php/topic,30540.msg185573.html#msg185573
Thanks mate, but unfortunately that's the kind of thing I wanted to avoid - manually validating form elements - I've got *hundreds* of fields! I was hoping eform could do the heavy lifting...
Logged
mrhaw
Committed to MODx
Posts: 1,087
modx == freedom
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #3 on:
Dec 22, 2008, 06:10 AM »
Maybe --->
http://modxcms.com/forums/index.php/topic,27794.0.html
//will stop spamming your post and leave it to someone who knows stuff
«
Last Edit: Dec 22, 2008, 06:13 AM by mrhaw
»
Logged
My playground:
http://4up2date.info
| Host: (mt) Media Temple (gs) | Server: Apache 2.0 | MySQL 4.1.11 | PHP 5.2.6 | MODx 0.9.6.3 (patchwork)
ZAP
Testers
Posts: 1,583
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #4 on:
Dec 22, 2008, 07:33 AM »
I think that you'd have to use an eForm event function to validate these fields separately, since the eform tag is processed when the form is first parsed afaik (if your function passes error messages to the eForm validation or required variable it will display them as usual). Could you make your injected variables into arrays? That would make looping through them in a function easier (although you could loop through the $_POST array and process any that begin with "Name", etc.).
Logged
"Things are not what they appear to be; nor are they otherwise." - Buddha
"Well, gee, Buddha - that wasn't very helpful..." - ZAP
Useful MODx links:
documentation
|
wiki
|
forum guidelines
|
bug reports
|
info you should include with your post
|
commercial support options
therebechips
Sr. Member
Posts: 305
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #5 on:
Dec 22, 2008, 09:44 AM »
@ZAP
Yes the injected content could use array notation for the field names - great idea
I'm wondering if eform would process these extra values despite them being injected, if the hardcoded template contains the first field with name="myFields[]" ? Since this would tell eform to treat the value as an array, and it presumably parses the entire $_POST array on each validation pass so it should pick up any extra values in the 'myFields' array.
When it comes to pre-populating eform with data (from a serialised object stored in a session or from a db), I think the idea of sending eform a customised template chunk could work (ie use a snippet to load the default chunk and then insert the extra fields into the markup) - although there would be some question over what happens if someone decided to then delete the additional form fields (using javascript) - would eform choke if an expected field was completely missing from $_POST?
Time for some experimenting I think. Thanks for your help guys.
Logged
ZAP
Testers
Posts: 1,583
Re: Can I Use eform to process form fields injected into the DOM with Javascript?
«
Reply #6 on:
Dec 22, 2008, 08:18 PM »
I have been able to prepopulate eForms and process fields that were not present in the original form chunk using eForm event functions. There are several examples in the MODx wiki that you might find helpful. If you push a value into the eForm fields or validation or required errors array from an event fuction, eForm will continue the process as if those values had come to it by the normal method.
Logged
"Things are not what they appear to be; nor are they otherwise." - Buddha
"Well, gee, Buddha - that wasn't very helpful..." - ZAP
Useful MODx links:
documentation
|
wiki
|
forum guidelines
|
bug reports
|
info you should include with your post
|
commercial support options
Pages: [
1
]
Go Up
Print
« Previous topic
Next topic »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Important News
=> Security Notices
-----------------------------
Commercial Support
-----------------------------
=> [CS] About Commercial Support
-----------------------------
Development & Coding
-----------------------------
=> Commercial Inquiries & Bounties
=> Core Code
===> MODx Next
===> xPDO
=> Module, Plugin & Snippet Creation and Modification
=> In Development
=> Templates
-----------------------------
Add-ons, Extensions & Elements
-----------------------------
=> Module, Plugin & Snippet Usage
=> General Repository Items Support
=> Navigation & Tagging/Taxonomy
===> Wayfinder & DropMenu
=> Creating & Repurposing Content
===> Ditto
===> Jot
===> Front-end Document Management
=> Users, Authentication & Personalization
===> WebloginPE
===> WebLogin, WebSignup and WebChangePwd
=> Rich Text Editors & File Browser
===> TinyMCE
===> FCKeditor
===> MCPuck File Browser
=> Forms, Form Processing & Anti-Spam
===> eForm
=> Search
===> AjaxSearch
=> E-business
=> Polls, Calendars, Address Book and Community
=> Third-party integrations
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> Backup & Versioning
===> Doc Finder
===> ManagerManager
===> PHx
=> Templates
-----------------------------
Support
-----------------------------
=> Release Support
===> 0.9.6.3
===> 0.9.6.2
===> 0.9.6.1
===> 0.9.6
===> 0.9.5 and earlier
=> General Support
===> MODx 101
===> E-Commerce, E-Marketing, Analytics & SEO
===> Hosting Experiences
===> IIS / Windows Hosting Issues
=> Documentation, Tips & Tricks
===> Documentation Suggestions & Corrections
-----------------------------
General Discussions
-----------------------------
=> General MODx Discussions
=> Webworker Lounge
=> Wishlist
=> You and Your Sites
=> modxcms.com Discussions and Suggestions
=> Off-topic
-----------------------------
International Support & Translations
-----------------------------
=> Internationalization
=> Bulgarian
===> Поддръжка
=====> Често задавани въпроси
=====> Инсталация
=====> Модули, Плъгини, Снипети и код
=====> Дизайн и Шаблони
===> Документация, Ръководства и Превод
=====> Документация
=====> Ръководства
=====> Превод
===> Общество
=====> Съобщения
=====> Представете се
=====> Представете сайта си
=====> Дискусии извън MODx
=> Chinese
=> Czech
===> Oznámení
=====> Důleitá oznámení/novinky
=====> Bezpečnost
===> Komunita
=====> Oznámení
=====> Představte se, prosím
=====> Ukázky práce
=====> Různé aneb cokoli co se jinam nehodí
===> Podpora
=====> FAQ (často kladené otázky)
=====> Instalace
=====> Moduly, pluginy, "snippets & code" (ablony zdrojových kódů)
=====> Design & ablony
===> Dokumentace, tutoriály (návody) a překlady
=====> Dokumentace
=====> Tutoriály (návody)
=====> Překlady (lokalizace)
=> Dutch
===> Ondersteuning
=====> Veel gestelde vragen
=====> Modules, Plugins, Snippets & Code
=====> Design & Templates
===> Documentatie, Tutorials en Vertalingen
=====> Documentatie
=====> Tutorials
=====> Vertalingen
===> Community
=====> Aankondigingen
=====> Stel jezelf voor
=====> Site Showcase
=====> De stamkroeg
=> Filipino
===> Suporta
=====> Kadalasang tanong
=====> Instalasyon
=====> Moduler, Maidadagdag, Karagdagang mga Code
=====> Desenyo at Templates
===> Dokumentasyon, Mga Turo, Mga Salin
=====> Dokumentasyon
=====> Mga Turo
=====> Mga Salin
===> Kumunidad
=====> Anunsyo
=====> Ipakilala ang sarili
=====> Ang Galing ng pinoy
=====> Tsismisan atbp
=> Finnish
===> Tuki
=====> UKK
=====> Asennus
=====> Moduulit, liitännäiset, koodinpätkät
=====> Ulkoasu/Sivustopohjat
===> Dokumentaatio, oppaat ja käännökset
=====> Dokumentaatio
=====> Käännökset
=====> Oppaat
===> Yhteisö
=====> Tiedotteet
=====> Esittele itsesi
=====> MODx sivustosi
=====> Kahvihuone
=> French
===> Support
=====> FAQ
=====> Installation
=====> Module, plugin, snippets
=====> Design/Templates
===> Documentation, Tutoriels et Traductions
=====> Documentation
=====> Traduction
=====> Tutoriels
===> Communauté
=====> Annonces
=====> Présentez vous
=====> Vos sites
=====> Le Bistrot Français
=> German
===> Support (de)
=====> FAQ (de)
=====> Installation (de)
=====> Module, Plugins, Snippets & Code (de)
=====> Design & Templates (de)
===> Dokumentation, Tutorials und Übersetzung
=====> Dokumentation
=====> Tutorials (de)
=====> Übersetzung
===> Community (de)
=====> Ankündigungen
=====> Stellt Euch vor
=====> Beispielseiten
=====> Off Topic / Verschiedenes
=> Hebrew
===> הכרזה
=====> חדשות חשובות
=====> אבטחה
===> תמיכה
=====> התקנה
=====> תיעוד, מדריכים ותרגומים
=====> עיצוב ותבניות
=====> שאלות נפוצות
===> תיעוד, מדריכים ותרגומים
=====> תיעוד
=====> מדריכים
=====> תרגומים
===> קהילה
=====> הודעות
=====> הצג את עצמך
=====> אתרים לדוגמא
=====> כללי
=> Irish
=> Italian
===> Supporto
=====> FAQ
=====> Installazione
=====> Moduli, Plugin, Snippet e altro codice
=====> Web Design e Template
===> Documentazione, Tutorial e Traduzione
=====> Documentazione
=====> Tutorial
=====> Traduzione
===> Comunitŕ
=====> Annunci
=====> Presentazioni
=====> Siti in vetrina
=====> Chiacchiere in libertŕ
=> Japanese
===> サポート
=====> 良くある質問
=====> インストール
=====> モジュール・プラグイン・スニペット・本体
=====> デザインやテンプレート
===> マニュアル・テュートリアル・翻訳
=====> マニュアル
=====> 事例集、テュートリアル
=====> 日本語化
===> コミュニティ
=====> お知らせ
=====> MODxサイト展示場
=====> 自己紹介
=====> 雑談
=====> 国産リソース
=> Persian - فارسي
===> پشتيباني
=====> راهنما
=====> نصب
=====> ماژول , پلاگین ها , کد ها و جزییات
=====> طراحی و قالب ها
===> مستند سازی , آموزش ها و ترجمه ها
=====> مستند سازی
=====> آموزش ها
=====> ترجمه ها
===> انجمن ها
=====> اخبار
=====> معرفی کردن خود
=====> نمایش دادن سایت ها
=====> بحث های عمومی و سایر موضوعات
=> Polish
===> Wsparcie
=====> FAQ
=====> Instalacja
=====> Moduły, pluginy, snipety i kod
=====> Wygląd i szablony
===> Dokumentacja, tutoriale i tłumaczenie
=====> Dokumentacja
=====> Tutoriale
=====> Tłumaczenie
===> Społeczność
=====> Ogłoszenia
=====> Przedstaw się
=====> Twój serwis WWW
=====> Hyde Park
=> Portuguese
===> Suporte
=====> FAQ - Dúvidas Frequentes
=====> Instalaçăo
=====> Módulos, Plugins, Snippets e Código
=====> Design e Templates
===> Documentaçăo, Guias e Traduçőes
=====> Documentaçăo
=====> Guias
=====> Traduçőes
===> Comunidade
=====> Anúncios
=====> Apresente-se!
=====> Bar da esquina (fora de tópico)
=====> Portfólio de Sites
=> Russian
===> Поддержка
=====> ЧАВО (FAQ)
=====> Установка
=====> Модули, плагины, сниппеты и код
=====> Дизайны и шаблоны
===> Документация, Уроки, Перевод
=====> Документация
=====> Уроки
=====> Перевод
===> Сообщество
=====> Объявления
=====> Представьтесь публике
=====> Галерея сайтов
=====> Диван
=> Scandanavian
===> Support
=====> Frĺgor och svar
=====> Installation
=====> Moduler, plugins, snippets och kod
=====> Design & sidmallar
===> Dokumentation, guider och översättningar
=====> Dokumentation
=====> Guider
=====> Översättningar
===> Webbgemenskap
=====> Meddelanden
=====> Presentera dig själv
=====> Visa upp dina webbsidor
=====> Ordet fritt
=> Slovak
=> Spanish
===> Soporte
=====> FAQ
=====> Instalación
=====> Modulos, Plugins, Snippets & Código
=====> Diseńo y plantillas
===> Documentación, Tutoriales y Traducciones
=====> Documentatción
=====> Tutoriales
=====> Traducciones
===> Comunidad
=====> Anuncios
=====> Presentaciones personales
=====> Muestra de sitios
=====> El Café
=> Swedish
=> TÜRKÇE (Turkish)
===> Destek
=====> SSS
=====> Kurulum
=====> Modüller, Pluginler, Snippetlar & Kodlar
=====> Dizayn & Temalar
===> Belgeleme, Eğitmenler ve Çeviri
=====> Belgeleme
=====> Eğitmenler
=====> Çeviri
===> Topluluk
=====> Duyurular
=====> Kendinizi Tanıtın
=====> Site Vitrini
=====> Konu Dışı